On Mon, 2002-11-18 at 16:22, Michael T. Babcock wrote: > Neulinger, Nathan wrote: > > >It's actually relatively speedy WITH the bad index, but maintaining that > >index (given it's lopsided nature) is very expensive. > > > >Yes, the point is to ONLY index the row if it matches the restriction. > > > > > > To clarify, if MySQL is indexing a binary value with lopsided > distribution, simply only keep an index of record locations for the > less-likely value. The more-likely value will end up being table-scanned. > > 'true', 'true', 'false', 'true', 'true', 'true' > ... 'false' -> 3rd row. > ... 'true' -> read the whole thing.
A BITMAP index will work efficiently in this case, no matter what the distribution of the keys is. The only requirement is that the column be low-cardinality. It basically works like this: true 011011111 false 100100000 One bitmap is stored for each possible value of the column. In this case the false bitmap shows that the first and fourth records should be return for false = '1'. A table scan would never be necessary, no matter what the distribution of values. -- Daniel Koch <[EMAIL PROTECTED]> --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php