MySQL Forums
Forum List  »  Optimizer & Parser

Re: Complex query - need advise
Posted by: Rick James
Date: November 05, 2012 11:12AM

As I read the query, it generates only 1 row of output. The Date and CampaignName are constants throughout? Will the subquery trick work for a broader query?

Another tip:
Store your Dates as DATE datatype. That is, rearrange d-m-Y into Y-m-d during INSERT. Then, don't hid columns in functions, at least when they are in an index:
AND date_format(str_to_date(mm.`Date`, '%d-%m-%Y'), '%Y-%m-%d') = '2012-10-29')
AND `Date` >= '2012-10-29'
AND `Date` < '2012-10-29' + INTERVAL 1 DAY

Those would allow you to take advantage compound indexes involving Date, and would allow ranges a better chance of being optimized.

Options: ReplyQuote

Written By
November 03, 2012 04:16PM
November 03, 2012 04:24PM
November 04, 2012 10:05AM
Re: Complex query - need advise
November 05, 2012 11:12AM

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.