MySQL Forums
Forum List  »  Optimizer & Parser

Re: Slow Union Query Opimization. Need help.
Posted by: Anthony Willard
Date: June 29, 2006 08:24AM

My first observation is that you are not grouping by all non-aggregrated columns. I've found this to be a troublesome practice - include all non-aggregated columns in your GROUP BY clause. This may be causing you some performance hit(s).

As for performance with large data, do you really need 5000+ rows on a query? Maybe you should limit your selection to a smaller set and then you could avoid the "large query" issues.

I'm not sure if derived tables actually get proper optimizer treatment with regard to indexes. You should try putting your data into a temporary table and then build an index or two that can aid with your final output. Divide and conquer.

Lastly, the larger the data fields you return, the larger the impact for "temporary" operations. For instance, if you are returning 10 fields that are 50 bytes each (ie char(50)), that's 500 bytes per row. Multiply that by 5000 rows and you get 2.5 million bytes! And that's just the data, not including the overhead. That's a lot of data to shuffle around.

HTH.

Anthony

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Slow Union Query Opimization. Need help.
3189
June 29, 2006 08:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.