Re: EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-25 Thread Johan De Meersman
On Thu, Feb 25, 2010 at 8:48 AM, Dan Nelson dnel...@allantgroup.com wrote: IN is fine ( for example ... WHERE field1 IN (1,2,3,4,5,6) is extremely efficient); it's subqueries in general that are killers. If the dependent subquery is nothing but index lookups, it's still blazingly fast, though

Re: EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-25 Thread Perrin Harkins
On Thu, Feb 25, 2010 at 2:48 AM, Dan Nelson dnel...@allantgroup.com wrote: IN is fine ( for example ... WHERE field1 IN (1,2,3,4,5,6) is extremely efficient); Yes, I meant to say IN/NOT IN subqueries, not value lists. it's subqueries in general that are killers. Subqueries in the FROM clause

Re: EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-25 Thread Baron Schwartz
Hello, On Wed, Feb 24, 2010 at 10:11 AM, Yang Zhang yanghates...@gmail.com wrote: I have the following query. Note that the nested query has no dependencies on the outer one, yet mysql reports it as dependent. Do an EXPLAIN EXTENDED followed by SHOW WARNINGS. You will see the optimization

EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-24 Thread Yang Zhang
I have the following query. Note that the nested query has no dependencies on the outer one, yet mysql reports it as dependent. Furthermore, it says the join type is an ALL (nested loop join, the slowest possible one, in which each row of the outer table results in a complete inner table scan),

Re: EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-24 Thread Perrin Harkins
On Wed, Feb 24, 2010 at 10:11 AM, Yang Zhang yanghates...@gmail.com wrote: Any ideas on how to optimize this by convincing mysql to see the independence use a const join? http://www.xaprb.com/blog/2006/04/30/how-to-optimize-subqueries-and-joins-in-mysql/ You need to rewrite as a join or use a

Re: EXPLAIN says DEPENDENT SUBQUERY despite no free variables

2010-02-24 Thread Dan Nelson
In the last episode (Feb 24), Perrin Harkins said: On Wed, Feb 24, 2010 at 10:11 AM, Yang Zhang yanghates...@gmail.com wrote: Any ideas on how to optimize this by convincing mysql to see the independence use a const join?