15/02/01 15:14, Quentin Bennett, [EMAIL PROTECTED]:
> Hi,
>
> I think you are mis-understanding the information provided. What the "using
> index" note means is that the isbn column is part of the index, and since
> that is all that is selected, the index file is used to provide the data,
> the data file is not touched.
You're right. From Explain doc:
Using index
The column information is retrieved from the table using only information in
the index tree without having to do an additional seek to read the actual
row. This can be done when all the used columns for the table are part of
the same index.
> Adding the author to the query means that the query now has to go to the
> data file to get the information, and since there is no restriction on isbn,
> the entire table is scanned for records to provide the result, which is then
> sorted. If you had an index of (isbn, author), then the index file would
> still be used.
That's where I don't get it, I don't want to sort by author, only by isbn.
Why does mysql needs to resort to a filesort while it has all the ISBN
neatly ordered in an index?
> Can someone else tell me and Francois, when the index is used like this, is
> the result pre-sorted, so the order by is trivial, or is a sort still
> performed.
Yes, how can we get mySQL to use an index for doing an order by? Must I
create an index for each and every possible fields combination?
Thanks for your lights on Using Index Quentin.
François Bélanger
Sitepak: nouvelle vision Internet pour l'entreprise
http://www.sitepak.com
---------------------------------------------------------------------
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