Solved

SQL server - Tempdb drive filled

Posted on 2012-04-05
7
635 Views
Last Modified: 2012-05-25
I am by no means a seasoned DBA but am learning.  Yesterday, we had a query that ran wild and filled up the drive tempdb was on.  There has got to be a way to prevent this from happening / a way to limit how much resources a single query can have.
0
Comment
Question by:niaidsdt
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Assisted Solution

by:DBengineer
DBengineer earned 100 total points
Comment Utility
The tempDB utilization depends on the batch statement written by the developer.

I would recommend the following to prevent.

Optimize the SQL statement.
(or)
Give enough disk space to accomodate enough tempDB growth.

Other than this I dont think you can limit the SQL batch to limit TEMPDB resource usage regardless of the SQL statemetns internal call for sorting and merging.
0
 
LVL 39

Assisted Solution

by:lcohan
lcohan earned 100 total points
Comment Utility
In SQL 2008 you have the Resource Governor available for that however you need some experience to use it (by any means I do not want to offend you as I understand that you are learning now) and please see link below for that.

http://msdn.microsoft.com/en-us/library/bb933866(v=sql.100).aspx


I suggest move tempdb on another location with sufficient drive space as this database is needed for mutliple reasons and you shouldn't (can't anyway) cap it. On another note tempdb is rebuilt everytime SQL Service restarts so is easy to move - just issue a ALTER DATABASE command and next restart will be created at new location.

http://support.microsoft.com/kb/187824
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
You can of course restrict the growth of tempdb, instead of allowing the default unrestrincted growth, but this will affect all queries and not just the one causing you grief.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:niaidsdt
Comment Utility
So i think it's fair to say that tempdb needs to grow and grow and grow.  There's next to nothing that you can do about it.

lets look at it from another direction.  Can we restrict the amount of data returned?  For example, what if someone says give me all data from every table.  This would obvioulsy put a serious strain on the SQL server.  Is there a way to limit how much data can be returned with a single query / how much memory a single query can use / how much cpu a single query can use?
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
Comment Utility
So i think it's fair to say that tempdb needs to grow and grow and grow.  There's next to nothing that you can do about it.
No, that is not entirely true.  You can restrict the growth but it will affect all queries.

Is there a way to limit how much data can be returned with a single query / how much memory a single query can use / how much cpu a single query can use?

Not to my knowledge.
0
 

Author Comment

by:niaidsdt
Comment Utility
Anyone ever use materialized views to solve this issue?
0
 
LVL 39

Expert Comment

by:lcohan
Comment Utility
"Is there a way to limit how much data can be returned with a single query / how much memory a single query can use / how much cpu a single query can use?"

You can use SET ROWCOUNT to ".... stop processing the query after the specified number of rows are returned."

http://msdn.microsoft.com/en-us/library/ms188774.aspx

and you can use "Resource Governor enables you to specify limits on the amount of CPU and memory that incoming application requests can use."

http://msdn.microsoft.com/en-us/library/bb933866.aspx
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now