June 17, 2009 at 9:23 am
Hello,
I have a temp table that shows up daily in the missing indexes report, provided by the performance dashboard report. The problem is that it in the form of tempdb.dbo.#3F3D11FA and I don't know how pin it down.
Any ideas on how I could find the actual name and/or proc that is executing it?
Thanks,
Scott
June 17, 2009 at 9:30 am
That's a table variable and, other than unique constraints, it can't be indexed.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 17, 2009 at 10:04 am
Ahh ok didn't know it was a table variable.
Is it the format of #xxxxxx that implies that is a table variable vs. temp table?
It still might be good to track it down and see if its better suited to a temp table. How would one approach that, is there enough info in the system views to track down the query associated with it?
June 17, 2009 at 10:29 am
digitalox (6/17/2009)
Is it the format of #xxxxxx that implies that is a table variable vs. temp table?
Yes. Temp tables have a name in TempDB that includes the name given to them at creation along with lots of ___ and a hash at the end, table variables get a name made up of a # and then some hex characters.
Temp table: create table #MyTable (id int)
Actual name in TempDB:
#MyTable____________________________________________________________________________________________________________000000000002
Table variable: DECLARE @myTable TABLE (id int)
Actual name in TempDB:
#07020F21
It still might be good to track it down and see if its better suited to a temp table. How would one approach that, is there enough info in the system views to track down the query associated with it?
As far as I'm aware, no. In all query plans it'll be referenced by the name it was declared with. I don't know of any way to tie the physical name back to a query.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 17, 2009 at 10:45 am
bummer that what i was afraid of. thanks for your help.
--
Scott
June 17, 2009 at 8:42 pm
digitalox (6/17/2009)
Hello,I have a temp table that shows up daily in the missing indexes report, provided by the performance dashboard report. The problem is that it in the form of tempdb.dbo.#3F3D11FA and I don't know how pin it down.
Any ideas on how I could find the actual name and/or proc that is executing it?
Thanks,
Scott
That's a table variable and, other than unique constraints, it can't be indexed.
Gail Shaw
I wonder if the "dashboard report" is using the table variable?
Oh Gail... did you forget that table variables can have primary key constraints also?
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 18, 2009 at 3:50 pm
I can tell by the columns its our code. Probably a proc that's stuffing more data than it needs to in a table variable and processing it. I know there's probably a lot of places that would benefit from an indexed temp table rather than a table variable.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply