• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

SQL server - Tempdb drive filled

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
niaidsdt
Asked:
niaidsdt
  • 2
  • 2
  • 2
  • +1
3 Solutions
 
DBengineerCommented:
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
 
lcohanDatabase AnalystCommented:
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
 
Anthony PerkinsCommented:
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
niaidsdtAuthor Commented:
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
 
Anthony PerkinsCommented:
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
 
niaidsdtAuthor Commented:
Anyone ever use materialized views to solve this issue?
0
 
lcohanDatabase AnalystCommented:
"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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now