SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Temp table query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Sean_B
Posting Yak Master

United Kingdom
111 Posts

Posted - 02/04/2010 :  06:30:17  Show Profile  Reply with Quote
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

India
22744 Posts

Posted - 02/04/2010 :  07:33:41  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

United Kingdom
111 Posts

Posted - 02/04/2010 :  09:48:26  Show Profile  Reply with Quote
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

India
22744 Posts

Posted - 02/05/2010 :  01:04:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

United Kingdom
111 Posts

Posted - 02/05/2010 :  05:46:51  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000