开发者

Can MySQL parallelize UNION subqueries (or anything at all)?

I use a partitioned table with a large amount of data. According to MySQL docs, it is on the ToDo list that:

Queries involving aggreg开发者_如何学Cate 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.

  • The queries are run in order
  • The data type of the columns is determined by the first query
  • By default, identical rows are dropped (UNION defaults to DISTINCT)
  • The result set is not finished building until all queries are run

...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.


I think a similar question was answered here. http://forums.mysql.com/read.php?115,84453,84453

(May be I should have posted this as a comment, but I honestly couldn't find a comment button anywhere around here.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜