Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
Tempdb issue
15 posts, Page 1 of 2
1
2
»»
Tempdb issue
Rate Topic
Display Mode
Topic Options
Author
Message
samsql
samsql
Posted Monday, May 17, 2010 5:12 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:40 AM
Points: 288,
Visits: 517
Hi Experts,
i have an issue wen i create a temp table it take
1 sec to create a temp table in temp db also wen i check it from the perfmon
the active temp tables shows more the 16 lacs of temp table
the table name in the tempdb shows as this #table_________________
Post #922805
blakmk
blakmk
Posted Monday, May 17, 2010 10:03 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:35 AM
Points: 136,
Visits: 327
temp tables are also created by other processes that perform sorts as part of their operation
Sql Server Blog
Sql Server Consultancy
Post #922987
samsql
samsql
Posted Tuesday, May 18, 2010 12:38 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:40 AM
Points: 288,
Visits: 517
yes but wat i m staying here is
there is a procedure in which there are around 30 more procedure which are getting called
Eg create procedure abcdef
(
begin
exec ab ---doing some operations creatin 5 temp table doing some updation,insertion etc
exec abc ---doing some operations creatin 5 temp table doing some updation,insertion etc
exec abe ---doing some operations creatin 5 temp table doing some updation,insertion etc
exec abd ---doing some operations creatin 5 temp table doing some updation,insertion etc
end
)
what i know that after the procedure is exec the temp tables gets destroyed from the tempdb.
but here in this senario the temp tables are not getting getting destroyed from tempdb.
they are getting dropped wen the abcdef procedure gets executed completly.
Also wen we r running this procedure from different session we are getting blocking on tempdb
while creating a temp tables within the procedures
Post #923316
blakmk
blakmk
Posted Tuesday, May 18, 2010 3:32 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:35 AM
Points: 136,
Visits: 327
looks like you are using global temporary tables which may cause blocking:
http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html
Sql Server Blog
Sql Server Consultancy
Post #923403
samsql
samsql
Posted Tuesday, May 18, 2010 5:48 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:40 AM
Points: 288,
Visits: 517
no not using global temp tables ...
Post #923477
samsql
samsql
Posted Thursday, May 20, 2010 12:35 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:40 AM
Points: 288,
Visits: 517
waiting for the reply...Jeff can u help in this process
Post #924840
Grant Fritchey
Grant Fritchey
Posted Thursday, May 20, 2010 5:27 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 3:48 AM
Points: 13,383,
Visits: 25,190
Temp tables last for the length of the process that created them. That wrapper proc is the process, so as long as it's running, you'll keep those temp tables. You can explicitly drop temp tables too.
What are the procs doing? It doesn't sound like you're using the temp tables in an efficient manner.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #925005
saby
saby
Posted Thursday, May 20, 2010 5:49 AM
SSC Veteran
Group: General Forum Members
Last Login: Friday, February 11, 2011 8:31 PM
Points: 297,
Visits: 277
Your process was involved in unresolved deadlock, therefore, the tables were not dropped and blocked the creating table process in tempdb.
This might be the bug in sqlserver 2005.
create proc proc1
as
begin
create table #abcd ( i int)
drop table #abcd
end
go
BEGIN TRAN
go
DECLARE @I INT
SET @I = 1
WHILE @I < 5000
BEGIN
EXEC proc1
SET @I = @I + 1
END
go
Select count(*) from tempdb.sys.tables
go
If you notice the last output, the tempdb now has 5000 temp tables. From a programmer perspective, as soon as a stored procedure finishes, the temp table scope is over and it is destroyed. In SQL2005 we do a deferred drop, but that doesn’t kick in until transaction is over.
Because of the begin tran command, the temp tables are not dropped and hence tempdb locks not released. However, these tables are no longer accessible even to the SPID which created it, but are still present in tempdb.
Saby DBA
Post #925018
samsql
samsql
Posted Thursday, May 20, 2010 6:00 AM
SSC Veteran
Group: General Forum Members
Last Login: Thursday, March 21, 2013 5:40 AM
Points: 288,
Visits: 517
yes saby i m gettin blocking in the tempdb.
Grant there are procedure with begin and tran
E.g
proc ssa
(
Begin tran
exec procedure1
-----create some temp table and do some updation,insertion etc on temp table and physical table as there are more than 5 tables in each proc ...
exec procedure2 -----create some temp table and do some updation,insertion etc on temp table and physical table as there are more than 5 tables in each proc ...
exec procedure3-----create some temp table and do some updation,insertion etc on temp table and physical table as there are more than 5 tables in each proc ...
commit
run with diffrent sessions got the blocking while creating a temp table
and one more thing is that the table creation takes 2 secs to create which is really more time.
it destroy the table after the 1 procedure get fully exec till commit.
Post #925025
Grant Fritchey
Grant Fritchey
Posted Thursday, May 20, 2010 6:26 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 3:48 AM
Points: 13,383,
Visits: 25,190
Saby, I'm confused. Where did you get deadlocks in this situation. We're talking about blocking. That's not the same thing as deadlocks.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #925045
« Prev Topic
|
Next Topic »
15 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.