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. 
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         kcarbone1970 
                                        Yak Posting Veteran 
                                         
                                        
                                        52 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-01-09 : 16:19:18
                                            
  | 
                                             
                                            
                                            | Hello i have a large cte query that queries hundreds of thousands of records and the wait time is around 40 seconds.  I've heard of ways to run the query before, store it in a temp table, then pull it from there, or something to that effect.  Can anyone here offer some insight or recommendations on how to expedite...thanks in advanceCartesian Yak | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     tkizer 
                                    Almighty SQL Goddess 
                                     
                                    
                                    38200 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-01-09 : 17:09:08
                                          
  | 
                                         
                                        
                                          | Please post the query, execution plan (xml format) and indexes on the tables so that we can help you.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     SwePeso 
                                    Patron Saint of Lost Yaks 
                                     
                                    
                                    30421 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-01-09 : 17:19:08
                                          
  | 
                                         
                                        
                                          The query I posted to you now runs in 2 seconds. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     tkizer 
                                    Almighty SQL Goddess 
                                     
                                    
                                    38200 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-01-09 : 17:19:47
                                          
  | 
                                         
                                        
                                          quote: Originally posted by SwePeso The query I posted to you now runs in 2 seconds. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
  Cross-post?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |   
     
     
            
              
	     |  
		
			
     
          
		 |