January 15, 2010 at 6:54 pm
Hello Experts!
In your experience, as a general rule which has better performance:
1 x Batch Query
exec "INSERT INTO tbl (col) VALUES (1); INSERT INTO tbl (col) VALUES (2);INSERT INTO tbl (col) VALUES (3);"
Or
n x Stored Procs
exec s_AddVal 1
exec s_AddVal 2
exec s_AddVal 3
Thanks for your expertise!
January 15, 2010 at 7:09 pm
"IT DEPENDS". 😉 Test it with multiple different procs yourself and see.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 15, 2010 at 7:11 pm
Also... we have a name for inserting just one row at a time using either method... RBAR which is another four letter word for "slow".
--Jeff Moden
Change is inevitable... Change for the better is not.
January 15, 2010 at 7:13 pm
I agree with Jeff, you need to test. It could go either way.
Make sure you test different situations and a variety of possible parameters.
January 15, 2010 at 7:31 pm
Thanks guys!!
When I run SQL profiler on the large enterprise web-apps I work on, I've always been astonished at the plethora of procs we developers typically call to fill a web page with data (over web services). And then again to process the data upon a form submit.
I thought a more efficient approach might be to package up all queries for that web page in a single batch, and execute it once. Rather than calling 20-30 procs for each little piece of data here and there as the code runs down the list of everything the page needs.
Same for the submit. Call a batch of all the sql needed to process that page, rather than just going down the code, save this: execute, wait for web services to come back, save that: execute, wait for web services, etc...
I first started thinking about this when reading some suggestions on strategies for cloud computing since I won't be using Service Oriented Architecture on a new project I'm starting.
Thought I'd see if anyone else out there has taken a similar approach or had thoughts from their experience.
Thanks again!
January 15, 2010 at 9:10 pm
bigj77s (1/15/2010)
I thought a more efficient approach might be to package up all queries for that web page in a single batch, and execute it once. Rather than calling 20-30 procs for each little piece of data here and there as the code runs down the list of everything the page needs.Same for the submit. Call a batch of all the sql needed to process that page, rather than just going down the code, save this: execute, wait for web services to come back, save that: execute, wait for web services, etc...
Now, if done correctly, THAT would most likely be true especially if you could rid of things like multiple INSERT/VALUE statements.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply