home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,595 of 19,505   
   Erland Sommarskog to rdshultz@nooter.com   
   Re: Stored Procedure - Insert VS Update   
   29 Jul 09 21:26:17   
   
   bc87e935   
   From: esquel@sommarskog.se   
      
   eighthman11 (rdshultz@nooter.com) writes:   
   > Quick question.   
   > I have a stored procedure were I created a workfile.  Several thousand   
   > records get inserted in this work file.  Is it normally quicker to   
   > join all the tables I need for the insert or is it faster to get all   
   > the base records inserted into the workfile then do one or more   
   > updates to the workfile using the other tables that I didn't join.   
      
   If you join all tables at once, the optimizer has the chance to compute   
   the best compute order. If you work with a temp table, and take table   
   one by one, you determine the compute order, once and for all. The optimizer   
   may pick one plan today, and another in six months when the data profile   
   has changed.   
      
   So joining all at once is usually better.   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
   SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca