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
 General SQL Server Forums
 New to SQL Server Programming
 Performance Question

Author  Topic 

amandl
Starting Member

3 Posts

Posted - 2015-01-05 : 06:54:49
Hi,
we have implemented a stored procedure which does a lot of numbercrunching (lots of selects in Loops, some updates in loops and so on)
the stored procedure called directly via the SQL Server console takes 5 Minutes to run
the same stored procedure called via an insert trigger in a queue table takes 2 seconds to run?!
any ideas why? We are thinking of a different transaction concept - that in the trigger all is being done in memory and flushed in one rush... or are we wrong?
is it a DB Design issu? What can be done, that the stored Proc called directly has the same performance?
thx

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-05 : 08:38:35
What can be done? Try to eliminate the loops you speak of. Use set-based logic instead.

Beyond that, you will need to post some code so we can take a look at it.
Go to Top of Page

amandl
Starting Member

3 Posts

Posted - 2015-01-05 : 09:08:49
quote:
Originally posted by gbritton

What can be done? Try to eliminate the loops you speak of. Use set-based logic instead.

Beyond that, you will need to post some code so we can take a look at it.



hi - no we are using the same stored proc - either called within an insert trigger - takes 2 seconds - or called directly - takes some minutes! - so that's what I am not understanding...
Go to Top of Page

amandl
Starting Member

3 Posts

Posted - 2015-01-05 : 09:18:42
so the solution is: putting a transaction arround the stored procedure - than it has the same speed...
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-05 : 09:25:58
Maybe. You haven't posted any code and your description has no details for anyone to work with. We can't confirm or refute your hypothesis.
Go to Top of Page
   

- Advertisement -