MySQL Forums
Forum List  »  Optimizer & Parser

Re: Need recommendation regarding IN expression
Posted by: Jay Pipes
Date: February 23, 2006 10:55AM

Solon Barns wrote:
> Thank you!
>
> I do need GROUP BY because I will be selecting
> time on page per registrant (I made a mistake in
> the first query).

Cool, looks like you got the query correct! :)

> BTW, you specified the s.report_id = 1569 as JOIN
> condition rather than WHERE condition, is it more
> efficient?

For an INNER JOIN, the optimizer is capable of understanding that having the report_id = 1569 is equivalent to filtering the selected_registrants table *before* doing the join to page_views. This is a stylistic thing that I have adopted for two reasons:

1) I believe it makes the SQL more clear in where the filter on report_id is occurring.
2) If you choose to at some point change the INNER JOIN to a LEFT JOIN, you have your filter in the correct place (the ON condition vs. the WHERE clause)

HTH

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Need recommendation regarding IN expression
2195
February 23, 2006 10:55AM


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.