Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel mysql queries in php?

I am sharding my data into multiple mysql databases, but sometimes I will need to gather information from multiple shards. How can I query multiple mysql databases in parallel in php?

I've seen some examples of asynchronous curl requests and shell_exec, but is there a more direct way?

like image 438
eshan Avatar asked Nov 26 '08 21:11

eshan


People also ask

How run multiple MySQL queries in PHP?

You can execute multiple SQL queries with multi_query , a built-in function in PHP. The SQL queries should be in a quoted string to make multiple queries with multi_query , but each SQL should be delimited with a semicolon. For the HTML and CSS, you can use the same HTML and CSS code from the previous section.

Does MySQL support parallel queries?

MySQL Cluster does not need a data management or name node like many other systems. Most queries run on all partitions on all nodes in parallel for maximum performance.

How run multiple MySQL queries?

Multiple statements or multi queries must be executed with mysqli::multi_query(). The individual statements of the statement string are separated by semicolon. Then, all result sets returned by the executed statements must be fetched.

What is parallel query in SQL?

Parallel query is a method used to increase the execution speed of SQL queries by creating multiple query processes that divide the workload of a SQL statement and executing it in parallel or at the same time.


1 Answers

The new mysqlnd driver can perform asynchronous queries. Documentation is sparse, but there are some examples (also relating to sharding) in a presentation here.

like image 191
Eran Galperin Avatar answered Oct 04 '22 07:10

Eran Galperin