List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:October 14 1999 1:29am
Subject:Possible to force index usage?
View as plain text  
Hi!

>>>>> "Peter" == Peter Andreasen <pandr@stripped> writes:

Peter> Hi,
Peter>   The Manual says:

Peter>     Each table index is queried and the best index that spans fewer than
Peter>     30% of the rows is used. If no such index can be found, a quick
Peter>     table scan is used. 

Note that the above only holds when you don't use LIMIT.

Peter>   Well, sometimes I do stuff like

Peter>     SELECT * FROM table WHERE id > 10000000 AND value='x' LIMIT 10;

Peter>   and the index on column id can only limit the rows by, say, 50%.

Peter> Is it possible to force mysql to use the index in this case? The 'quick'
Peter> table scan is not _that_ quick when it has to go through >10M rows :-)

Using LIMIT, like above, should force MySQL to use the index instead
of doing a table scan.

Regards,
Monty
Thread
Possible to force index usage?Peter Andreasen13 Oct
  • Possible to force index usage?Michael Widenius14 Oct