Solved

SQL server - Tempdb drive filled

Posted on 2012-04-05
7
642 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
ID: 37813919
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 40

Assisted Solution

by:lcohan
lcohan earned 100 total points
ID: 37813927
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
ID: 37814861
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:niaidsdt
ID: 37815790
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
ID: 37816999
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
ID: 37899370
Anyone ever use materialized views to solve this issue?
0
 
LVL 40

Expert Comment

by:lcohan
ID: 37899455
"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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

680 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