Re: Is Union Queries run in Parallel form or not.
Hi,
> I wan to ask that these queries run in parallel
> form or in order one by one ?
They will be run one by one. MySQL does only use one thread per connection.
> What can I do to increase the performance of this
> query. Can I create thread for each query ?
Only way to get one thread per query is to run each query in a separate connection. Note that this implies that the queries will run in different transactions, and possibly see a different set of concurrent updates.
> If I create three thread for this query with
> single connection is it work in parallel or not ?
Traditionally, a connection can only have one outstanding request at a time, so the queries can not be run in parallel if using the standard MySQL Protocol. However, you can get asynchronous execution by using the X Plugin for MySQL. See
https://www.percona.com/blog/2016/05/27/asynchronous-query-execution-mysql-5-7-x-plugin/ for an example.
> or I need to create three connection for each
> query to run parallel ?
Yes, unless you use the XPlugin.
Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway