Parallel Processing Query in Sql Server 2008

  • Hi friends,

    Is it possible to process the 2 or more query at one time in Sql Server 2008?

    I heard the processing of 2 or more partition table is possible in Sql Server 2008?

    I am not sure, it is possible or not, if yes, can u give me some hints how to make it?

    Cheers!

    Sandy.

    --

  • You need to be a bit more specific about what you are trying to do.

    All versions of MS SQL have been able to process two queries at the same time on different connections (probably not what you mean). Since SQL 7, there has been a parallel processing engine that processes individual queries on multiple threads. Since SQL 2005, MARS has allowed the parallel (not technically parallel, actually) return on multiple recordsets on a single connection.

  • Michael,

    Yup, I do agree what you said, but my question is bit different here.

    just assume this case you will come to know more..

    I have query like this:

    Begin

    Query 1

    Query 2

    Query 3

    End

    now what is happening here, if you execute this query, it will execute one bye one, and takes 1 minutes each and total 3 minutes. i mean to say the batch not executing simultaneously, as like thread management.

    what i wants:

    Begin

    Thread - 1 : Query 1

    Thread - 2 : Query 2

    Thread - 3 : Query 3

    End

    now what I wants here, if you execute this query, it will execute at once, and will take only 1 minutes not to take 3 minutes to complete the task. I am not sure its possible in Sql Server or Not??

    Cheers!

    Sandy.

    --

  • No, it is not possible in any version of SQL Server to do that in T-SQL. You would have to run the three queries from three individual connections.

  • This is something normally handled on the client, as was already said. But, you could use a CLR query to do it. I wouldn't recommend it, but it is possible. Then, what happens is, you call out to the CLR code and being .NET, it can spawn multiple threads and multiple connections to process the different queries.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • From the CLR, you can do this, but I think you have to run it as unsafe to create a new thread. Also, the context connection is not available in new threads.

    It gets pretty complicated to deal with fast.

  • No doubt. I wouldn't do it. Ever. I was just pretty sure that it was possible. It's also possible to stick my fork into my thigh... I'm not doing that either.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • It may depend on the type of fork.

    A plastic fork would need to be of reasonable quality. A spork would probably not work at all.

  • It's ok.

    Let me try using CLR...

    Cheers!

    Sandy.

    --

  • Michael Earl (7/21/2008)


    From the CLR, you can do this, but I think you have to run it as unsafe to create a new thread. Also, the context connection is not available in new threads.

    It gets pretty complicated to deal with fast.

    Plus, since the new threads you've spawned weren't created by SQL, they're not wrapped in a structured error handler (unless you do it yourself or .Net does it automatically for all new threads). Throw a windows exception from one of them and you could bring the entire SQL service down.

    Ken Henderson had a section on that (using xps not CLR) in his book on SQL architecture.

    Sandy: Rather do't go for CLR. It's more complex and unsafe assembiles are just that. Unsafe. If you need to run multiple queries at a time, do that from the front end app, not from within SQL.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • gail,

    A hearty thanks to you, I just expected this answer, what you just now explained here. It may be possible in .NET integration(CLR) but seems not to do with SQL Side..

    Thanks again for same..

    Cheers!

    Sandy.

    --

  • Your previous post scared me. I wasn't entirely kidding about sticking a fork in myself as a comarison. Using CLR is of questionable benefit in most situations. This one is just asking for serious trouble. I'm sorry I ever suggested it was a possibility because it's frankly a foolish thing to do.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant,

    As you suggested to my topic that CLR is an option to achieve this, I do agree. But as per my concern, its not possible in TSQL even in SQL Server 2008. I heard about it so I wants to clear my concepts and know what is correct? As you suggested it can be achieve by CLR. its good to know this.

    Anyways thanks to you..:)

    and I am here to know better and share my experience..

    Cheers!

    Sandy.

    --

  • You cannot do what you are suggesting in T-SQL, even in SQL 2008.

  • ok,

    Cheers!

    Sandy.

    --

Viewing 15 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic. Login to reply