OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Composite Index Usage in Joins

From: Jeffrey Grollo (grollojgmail.com)
Date: Thu Jul 12 2012 - 11:06:36 CDT


Thanks for the guidance and references, Shawn.

On Wed, Jul 11, 2012 at 3:37 PM, Shawn Green <shawn.l.greenoracle.com> wrote:
>
> Ranged scans only happen for the last portion of an index being used. OR
> queries (or those using IN) can also only be applied to the last part of an
> index search. This means that if you are using IN (or OR) against the first
> part of an index, that's where the usage of the index stops.

Basically, this is what I was expecting. However, in the second table
in the join, the secondary column wasn't being used for the range or
IN. I was expecting, given the nested-join loop algorithm (as I don't
believe that BNL would be used
http://dev.mysql.com/doc/refman/5.5/en/nested-loop-joins.html), that
the first column in the key would be treated as const allowing the
second column to be used in a range or IN criteria.

>
> Also, trying to force index usage may be creating more work for your disks
> than necessary.

I should have indicated in the original post that I was forcing the
index simply to make the example work without data.

Regards,
Jeff

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql