-1

I want to know If we can execute multiple queries at the same time in MYSQL/SQL. Let me explain a case scenario to elaborate my statement further.

Let's Assume, We have to create and load two tables.create table tbl1(col,col,col,col...); Insert Into tbl1 (val,val,val,val...) and other query as create table tbl2(col,col,col,col...); Insert Into tbl2 (val,val,val,val...). Now, When I execute the statement the flow will be

  1. Create Table1
  2. Insert Into Table1
  3. Create Table2
  4. Insert Into Table2

Is there any method We can use to minimize these 4 steps into a single step? Similar to the functionality of threads that run in parrallel.

2 Answers 2

0

You can use two different instances of SSMS or may be different tabs within SSMS.

Other solution to run 2 queries at the same time with a maintenance plan. Here is the link for more details

Sign up to request clarification or add additional context in comments.

1 Comment

SSMS is used with MSSQL/SQL-SERVER not mysql...and the link provided is sql-server.
0

You can chain multiple queries by using the ";", see here for further details: How to run multiple SQL queries?.

In your setup, 1. needs to be executed before 2. (same is true for 3. before 4.) because you cannot insert data into a database that did not exist. So running these 4 queries in parallel is not possible. However, running 1+2 and 3+4 in parallel is possible.

2 Comments

Thank You @Tom Hammerbacher for your response. One more question. Is it possible to execute Create+Insert Query, Select Query and assume an update query in parallel?
You are welcome! As far as i know this is not possible by default without changing the server to include multiple threads. This may help you but it requires changes on server side: percona.com/blog/2019/01/23/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.