I use a partitioned table with a large amount of data. According to MySQL docs, it is on the ToDo list that:
Queries involving aggregate functions such as SUM() and COUNT() can easily be parallelized.
... but, can I achieve the same functionality using UNION subqueries? Are they parallelized, or do I have to create a multithreaded client to run concurrent queries with all the possible partition keys?
Edit:
The question is not strictly about UNION or subqueries. I would like to utilize as many cores as possible for my queries. Is there any way to do this (and make sure it's done) without paralellizing my application?
Any good documentation about MySQL's current parallelizing capabilities?
As far as I know, currently the only way to use more than one thread/core to run queries in your application, is to use more than one connection. This of course makes it impossible to run parallel queries that are part of a single transaction.
The different queries that are UNIONed together in one larger query aren't really subqueries, strictly speaking.
...there is no way to parallelize the different queries, as they are all really part of the same query.
You may want to try runing the different queries in parallel from your code, and then mashing the results up together in your code once the queries all complete.
The documentation on UNIONs can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With