SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TempDB usage per active session


TempDB usage per active session

Author
Message
Gianluca Sartori
Gianluca Sartori
SSCrazy Eights
SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)

Group: General Forum Members
Points: 9882 Visits: 13350
Comments posted to this topic are about the item TempDB usage per active session

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Nadrek
Nadrek
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1899 Visits: 2729
Very interesting, though I'd find a version that looks for not only internal objects, but also explicit objects like #temp and ##global temp tables, and even "real" tables in tempdb, etc. etc., which in my environment are (regrettably, in the case of the "real" tables) common.
Matija Lah
Matija Lah
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2995 Visits: 380
Thanks for helping me identify a query where by using OPTION(RECOMPILE) I was able to reduce execution time of "completely unpredictable" to a few seconds. :-)

ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
Gianluca Sartori
Gianluca Sartori
SSCrazy Eights
SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)

Group: General Forum Members
Points: 9882 Visits: 13350
My pleasure, Matija!
Was the query using a lot of tempdb space? I'm curious to know how OPTION RECOMPILE made it stop doing so. Maybe a wrong cached plan?

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Matija Lah
Matija Lah
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2995 Visits: 380
The query is used for a rather complex computation needed in the result of a highly used stored procedure.

Occasionally, the execution plan would include a Hash Join operator in a particular JOIN clause that worked well for some workloads, but ended up creating multi-million-row work tables for other workloads, where a paralel plan using the Merge Join, and Nested Loops, operators would have been more appropriate.

Because of the complexity of the query (which someone else, other than myself should also be able to maintain ;-)), I didn't want to complicate things further, either by using explicit join hints (i.e. in specific JOIN clauses), or by specifying query-level join hints (e.g. OPTION(MERGE JOIN, LOOP JOIN), which would have prevented the use of the Hash Join operator altogether.

OPTION(RECOMPILE) does cause some overhead (which isn't completely insignificant), but it keeps the behavior of this particular query predictable. Considering the full scale of what the procedure is used for, this is a highly significant benefit.

ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
webrunner
webrunner
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4157 Visits: 3886
Thanks so much for this query. Is there a similar one for retrieving tempdb log space used per SPID?

I'd like to track such a query for an issue where an as-yet unknown query is causing periodic large increases in the percent of log space used.

Thanks for any help!

- webrunner

-------------------
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
Ref.: http://www.adminarsenal.com/admin-arsenal-blog/powershell-how-to-write-your-first-powershell-script

"Operator! Give me the number for 911!" - Homer Simpson

"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Roshan Jospeh
Roshan Jospeh
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1615 Visits: 2087
Nice and useful script! Thanks!

----------------------------------------------------------------------------------------------------------------------------------------------------
Roshan Joe

Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13860 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search