Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Temp table query

Author  Topic 

Sean_B
Posting Yak Master

111 Posts

Posted - 2010-02-04 : 06:30:17
Hi,

when I do a select * into #temp from mytable I get a given number of reads on mytable.

However when I create the #temp table first and do an insert

insert into #temp select * from mytable.

I get the same number of reads on mytable, but also reads on #temp.

Why is it doing this and how can I avoid it, any suggestions appreciated.

Sean


Sean

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-04 : 07:33:41
Your question is not very clear
What do you mean by reads?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sean_B
Posting Yak Master

111 Posts

Posted - 2010-02-04 : 09:48:26
When I set the statistics on I get the following logical reads on the temp table

Table '#Temp2______________________________________________________________________________________________________________00000000A731'.
Scan count 0, logical reads 294136, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.


Sean
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-05 : 01:04:44
quote:
Originally posted by Sean_B

When I set the statistics on I get the following logical reads on the temp table

Table '#Temp2______________________________________________________________________________________________________________00000000A731'.
Scan count 0, logical reads 294136, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.


Sean


Ok. What is your problem?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sean_B
Posting Yak Master

111 Posts

Posted - 2010-02-05 : 05:46:51
It is more of a question than a problem, why does the insert perform logical reads on the temp table it is inserting into, there are no keys or id columns on this table.

Sean
Go to Top of Page
   

- Advertisement -