Execute multiple queries on a single connection simultaneously.

  • 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


    What I hear I forget, what I see I remember, what I do I understand

  • Have you tested the following?

    EXEC proc 1

    EXEC proc 2?



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • 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.

  • 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.


    What I hear I forget, what I see I remember, what I do I understand

  • 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?

  • 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.


    What I hear I forget, what I see I remember, what I do I understand

  • 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 .

  • Should've read your reply on Monday morning


    What I hear I forget, what I see I remember, what I do I understand

  • Why, you'll have to take the day off now??

  • 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

  • The keyword here is "asynchronus"... all queries running at the same time from the same connection... Looking forward to Yukon .

  • 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.


    What I hear I forget, what I see I remember, what I do I understand

  • Maybe you should ask him (as I'm not .net either)... but I don't think that this is what you want.

  • 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

  • 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