MySQL Forums
Forum List  »  Optimizer & Parser

Re: optimize range query(using between, group by and order by)
Posted by: Øystein Grøvlen
Date: March 20, 2018 03:52AM

Hi,

It is a bit difficult to say how much improvement you will get without knowing the selectivity of the WHERE predicates, but the most optimal index will be on (customer_id, company_id, date) in that order.

I also suggest to remove the GROUP BY clause and use 'SELECT DISTINCT' instead. Makes it more clear what is the objective here.

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: optimize range query(using between, group by and order by)
821
March 20, 2018 03:52AM


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.