• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

processing two queries at the same time

I have a stored procedure that loads data from two sources into temporary tables then merges the results.

The imports run sequentially, ie INSERT #1 runs to populate temp table 1, then INSERT #2 to populate table 2....

I want to speed up the operation by running both inserts at the same time. Is that possible in SQL server?
1 Solution
Interesting question.  I'll be interested in a better answer than mine.

You could combine the operations into a single sql statement and hope that sql server will optimize it with parallelization.

Otherwise the only thing comes to mind would be to host the load operations outside of sql, either in another application or sql agent.  For instance you could make each load a sql agent job and then have a proc that starts both jobs and polls them waiting for completion before using the results (though this seems pretty ugly).

Practically speaking, I might guess the best answer is "no"
The quickest way would be outside of SQLbut not sure if it is appropriate to do in SSIS; internally mastoo is probably correct.
You can perform these tasks in parallel by creating 2 dataflow tasks that run concurrently in an SSIS package and run package via sql agent task.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now