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)
 query run time (which should be faster?)

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-28 : 20:21:46
Hi, when I execute the sql in DBTestArchive and then DBTest query analyzer , I found that the run time is shorter in DBTest. Can I make assumption that the query run time is shorter in DBTest if I select data from it and insert into another database? Thanks.



INSERT INTO DBTestArchive.dbo.tblVendorMasterArchive
SELECT * FROM DBTest.dbo.tblVendorMaster

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-02-28 : 21:46:36
That depends, and no, you can't make that assumption.

If the read is from one drive, and the destination is on another, that will be marginally faster (depending on table size) than reading/writing to the same drive.

Insert into is faster than Select INTO for table population.

Select * is slower (sometimes, depends again) than a select with identified column names. (The * makes SQL have to go to it's system tables to figure out the columns to pull and map them against the destination in your example.




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -