Wednesday, 15 January 2014

sql server - Several cursors at once -



sql server - Several cursors at once -

there table #costs (id,tree_id,date,value) holds info calling sp exec sp @tree_id,@date,@value output in order calculate complex service routine identified tree_id. in order set @value cursor used. how create several cursors working same #costs table? many rows in costs -> cursor sp runs long. cannot turn inline function or simplify sp logic has many internal sp callings, temporary inserts/updates etc. way parallel cursors? can avoid using agent jobs or service broker?

since have given question without (imo) plenty detail, sick give general solution have used in past similar problem. divided workload 'buckets', called several stored procedures run workload against given bucket. in case used separate powershell instances execute sps because moving lot of log files around, agent jobs job. create sure of course of study each 'bucket' can processed independently.

performance did increase, maintain eye out lock , latch activity , other bottlenecks, in case found there point of diminishing returns, 1 core per bucket seemed work me.

if willing work .net option, if dont want set jobs in agent: sqlcommand.beginexecutenonquery http://msdn.microsoft.com/en-us/library/7b6f9k7k%28v=vs.110%29.aspx

sql-server multithreading stored-procedures sql-server-2008-r2 cursor

No comments:

Post a Comment