MySQL Forums
Forum List  »  Optimizer & Parser

Re: Where Clause Optimization
Posted by: Øystein Grøvlen
Date: September 03, 2018 02:45AM

Mohammed Yehia El Sayed Abdoh Wrote:
> I already created a test case with all
> posdibilities and couldn't note any differences in
> the result set. That's why I am asking

Not sure why you would expect to see any differences in the result set. The whole point of optimizations is to find more efficient ways to execute the query without changing the result.

That HAVING is merged with WHERE means that if you have a query like:

SELECT * FROM t WHERE a = 1 HAVING b = 2

it is converted to:

SELECT * FROM t WHERE a = 1 AND b = 2

If you use EXPLAIN FORMAT=JSON, you can see the condition that will be attached to the table:

"attached_condition": "((`test`.`t`.`a` = 1) and (`test`.`t`.`b` = 2))"

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

Options: ReplyQuote


Subject
Views
Written By
Posted
503
August 31, 2018 01:55PM
Re: Where Clause Optimization
597
September 03, 2018 02:45AM


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.