Parallel Processing Query

Answered Parallel Processing Query

  • Monday, January 21, 2013 7:00 PM
     
     
    Is it possible to process the 2 or more query at one time in Sql Server ?I heard the processing of 2 or more partition table is possible in Sql Server ?
    I am not sure, it is possible or not, if yes, can u give me some hints how to make it?

All Replies

  • Monday, January 21, 2013 7:05 PM
     
     
    MS SQL have been able to process two queries at the same time on different connections .From the version SQL server 7, 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 record sets on a single connection. Can you please more specific about what you are trying to do ?

    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Monday, January 21, 2013 7:07 PM
     
     
    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
  • Monday, January 21, 2013 7:11 PM
     
     Answered
    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.    

    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

    • Marked As Answer by Tomas85 Monday, January 21, 2013 7:22 PM
    •  
  • Monday, January 21, 2013 7:21 PM
     
     
    It's ok.

    Let me try using CLR...
  • Monday, January 21, 2013 7:35 PM
     
     
    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.    
  • Monday, January 21, 2013 9:34 PM
     
     Proposed Has Code

    There are two different things:

    1. for a SQL Server with access to more than one CPU, SQL Server can decide to parallelise, ie split the load up and spread across multiple CPUs.  This can happen with partitioned tables, although this is better implemented in SQL 2008 onwards.
    2. You can run multiple queries against SQL Server with different connections.  eg you can do this with multiple windows open SSMS, multiple SSIS Execute SQL Tasks, custom .net client etc.  I probably wouldn't use CLR this for this.  I sometimes use the command-line to do this type of thing, eg
    for /L %f in (1,1,2) do start sqlcmd -i c:\temp\temp.sql -S.\sql2012 -dtempdb

    Which is you reallly need to run?  Have a single query parallelise out, or run multiple queries?

    Have a look through these articles for more detail on parallelism.

    Parallel Query Processing
    http://msdn.microsoft.com/en-us/library/ms178065(v=sql.105).aspx

    Query Processing Enhancements on Partitioned Tables and Indexes
    http://msdn.microsoft.com/en-us/library/ms345599(v=sql.105).aspx