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 |
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2011-09-23 : 05:00:30
|
Hi,I have the following stored proc which is taking quite long time to execute and looking for a way to optimize it.Create procCheck table exists,else create tableinsert records into temp tableinsert into table above temp table the differences/new records-------------The problem or wierdest thing im having is that when I run the code seperately from the stored procedure it runs quite alot faster than when I run 'exec sp etc...'a little education would be much appreciated!thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-23 : 05:23:02
|
are you using parameters in sp?what will be amount of records that will get inserted to temp table?Are you creating proper indexes in itDId you check execution plan and see which step takes maximum cost?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2011-09-23 : 05:42:47
|
There are no parameters and no dynamic sql.The temp table probably loaded around half a mill to 1.2 mill records depending on where i look at.But not using any indexing, can you advise?quote: Originally posted by visakh16 are you using parameters in sp?what will be amount of records that will get inserted to temp table?Are you creating proper indexes in itDId you check execution plan and see which step takes maximum cost?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-23 : 05:46:27
|
check execution plan and see costly steps first.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Kristen
Test
22859 Posts |
Posted - 2011-09-23 : 06:52:59
|
Post the code for us to have a look at please |
 |
|
|
|
|