October 27, 2006 at 9:48 am
Thanks Jeff, Matti and John for correcting me and clearing up my knowledge of Temp Tables/table variables. I'm glad Hector got a sound response.
SQL guy and Houston Magician
October 27, 2006 at 5:21 pm
We're all in this together and I'm pullin' for ya" --Red Green
And, thanks for the feedback, Robert... that's what this is all about.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2006 at 9:07 am
i have done a test and when i created a temp table i watched the table's name appears into tempbd, but then the temp tables always write into disk no matter if them are small??
October 30, 2006 at 12:20 pm
Run this:
select * from tempdb..sysobjects
declare @Temp TABLE (ID int)
select * from tempdb..sysobjects
What do you see?
_____________
Code for TallyGenerator
October 30, 2006 at 12:43 pm
Run this
select * from tempdb..sysobjects
create table #temp ( a int)
select * from tempdb..sysobjects
what do you see?
i refered to a temporal table and not to var temp table
Thanks
October 30, 2006 at 2:12 pm
Did you actually run it?
Did you notice any difference between @temp and #temp?
_____________
Code for TallyGenerator
October 30, 2006 at 2:44 pm
In my sql your query not appears the name of var temp into list and in my query appears the name of temporal table #temp into list
My query :
select * from tempdb..sysobjects
create table #temp ( a int)
select * from tempdb..sysobjects
October 30, 2006 at 2:48 pm
Did you look closely?
Run it again:
select * from tempdb..sysobjects
create table @temp ( a int)
select * from tempdb..sysobjects
and tell me how many rows come from 1st select and how many from 2nd one.
Find what is causing the difference.
_____________
Code for TallyGenerator
October 30, 2006 at 3:08 pm
well nothing because you uses '@' for the create table , so fixed that i saw the var temp name #7F16D496 , yes i realized that both write to disk , mmm well i imagine that var tables have more chache enables than a temporal table???
October 30, 2006 at 3:55 pm
What do you mean by "var tables have more chache enables than a temporal table"?
_____________
Code for TallyGenerator
October 30, 2006 at 4:31 pm
Temp tables do NOT always write to disk if they are small... do see Q4of the following URL which I've now posted 3 times in this thread...
http://support.microsoft.com/default.aspx?scid=kb;en-us;305977&Product=sql2k
... which says...
Q4: Are table variables memory-only structures that are assured better performance as compared to temporary or permanent tables, because they are maintained in a database that resides on the physical disk?
A4: A table variable is not a memory-only structure. Because a table variable might hold more data than can fit in memory, it has to have a place on disk to store data. Table variables are created in the tempdb database similar to temporary tables. If memory is available, both table variables and temporary tables are created and processed while in memory (data cache).
--Jeff Moden
Change is inevitable... Change for the better is not.
October 31, 2006 at 6:08 am
well but the name of table variable appears like a name of pointer to memory in my tempbd when it is declared, or my server's memory is not avaible or i guess that the structure of the table variable always is copy to disk and only when the memory cache is not avaible it begins to fill or isnt???.
Viewing 12 posts - 16 through 26 (of 26 total)
You must be logged in to reply to this topic. Login to reply