July 8, 2005 at 5:05 am
Hi guys.
Can we fire multiple queries on the same connection simultaneously? I mean a batch query comprising of multiple select statements, which gets executed in a single go. I know that we can sequentially fire the queries one after the other, but is it possible in SQL Server 2000 that we fire two or more queries simultaneously?
The idea is to have these queries executed in a single batch so that if I have 2 queries in the batch these get executed “simultaneously” instead of “sequentially” and I get the result set (in this case 2 result sets) quicker due to the simultaneous execution.
Is this possible?
Thanks in advance
July 8, 2005 at 6:11 am
July 8, 2005 at 6:25 am
He wants asynchronus execution. It think that your best bet is to start 2 threads in the application and opening 2 recordsets using 2 connections. This can be done on a server but you won't be able to get both recordsets at the same time.
July 8, 2005 at 7:08 am
Yeap, asynchronus execution is a good term to describe what I am looking for. The only hitch is that it needs to be on the same connection. 🙁
Eg: Queries Q1 and Q2
Connection C1
Execute Q1 and Q2 on C1 asynchroniously (together/same time/parallel)
Thanks for the replies.
July 8, 2005 at 7:15 am
Can't be done. You can't garantee that one execution will end before the other and I don't think that 2 records set would be returned anyways.
How long does it take to run those queries?
July 8, 2005 at 7:26 am
We are developing a solution and are analyzing all the possible ways to optimizing query preparation and execution. So as of now I don’t have any issues with my query execution, but some forward thinking going on here ;-).
I mentioned 2 queries in the example, but it would be 1 or even 10. Would have been great if SQL Server would've provided a mechanism to execute more than one query on the same connection simultaneously. In that case the query optimizer would have to make that choice of parallel execution, I guess.
Appreciate your interest Remi.
July 8, 2005 at 7:50 am
Well it can be done on the server. But the way it is done is to create a new connection in the proc and execute a statement in that connection... So we're kind of going in circles now .
July 8, 2005 at 7:55 am
Should've read your reply on Monday morning
July 8, 2005 at 8:00 am
Why, you'll have to take the day off now??
July 8, 2005 at 8:35 am
You can sena a bunch of select statements in one batch and it will be executed in one go! You will get multiple resultsets that you can loop on at client side.
What you can't (in 2000) is: while the batch is executing send another one. Fortunately 2005 supports MARS which will allow you to do it !
cheers!
* Noel
July 8, 2005 at 8:47 am
The keyword here is "asynchronus"... all queries running at the same time from the same connection... Looking forward to Yukon .
July 8, 2005 at 8:51 am
Not physically , but mentally i could've
MARS
http://www.codeguru.com/Csharp/Csharp/cs_network/database/article.php/c8715__1/
I'm not much of a DOT net guy, but I did show this to someone who I think knows DOT net well, and he said that its not the answer to what I need.
July 8, 2005 at 8:55 am
Maybe you should ask him (as I'm not .net either)... but I don't think that this is what you want.
July 8, 2005 at 9:29 am
MARS do provide what you asked for:
Execute multiple queries on a single connection simultaneously
And asynchronuos excecution is being supported even by ODBC since a long time ago therefore the key is not "asynchronuous". And what is more why do you need that again? What will be the problem of sending multiple select statements in one batch?
* Noel
July 8, 2005 at 9:31 am
Are you missing those words already???
I a g r e e .
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply