
For double-indexes you can perform following queries that will result in using the index: * match full value * match leftmost prefix (what I tried to explain) e.g. Match a full last_name. * match column prefix e.g. Match all last_names starting with 'A%'. * match a range of values e.g. match all last_names between Billiau and Van Bel * match one part exactly and a range on antoher part e.g. match last_name exact and and a range query on firstname. This is simply an extension of the leftmost prefix. * covering index query e.g. you only query and SELECT last_name and first_name. this is lightning fast as all the info is stored in memory anyway. Again, rule of thumb is, match from left to right ;) hh, Kenny On Thu, 15 Jul 2010, Michiel Van Bel wrote:
okay, I'm a bit confused: http://dev.mysql.com/doc/refman/4.1/en/multiple-column-indexes.html
You see 2 examples at the bottom, where the name index is NOT used. I understand why the index is not used in the first example, but why is it not used for the "last_name" part in the query of the second example?
I think I need to revise my knowledge on indexing a bit :-/
-- ====================================================================== Kenny Billiau Bioinformatics Group / GoFORSYS Scientific Programmer +49 331 567 8626 billiau@mpimp-golm.mpg.de Max Planck Institute for Molecular Plant Physiology Am Mühlenberg 1, 14476 Potsdam-Golm, Germany http://bioinformatics.mpimp-golm.mpg.de http://www.goforsys.de ======================================================================