I have a concern regarding how an index is being used for a query.  I've
included the query (minus the fields) and the EXPLAIN output below.  I'm
curious why MySQL would indicate that it's using filesort for table 'd'
since it's type is 'const.'  The documentation indicates this means that
only one row matched (which is true) and that it will use the fields from
that table as constants through the rest of the query.   Is this normal?
The query is fast, but I want to make absolutely certain that it is
perfectly optimized.

select ...somefields...
 from thread a, user b, user c, forum d
 where d.forum_id=1 and
  a.forum_id=d.forum_id and
  a.forum_id = 1 and
   a.owner_id = b.user_id and
  a.reply_id = c.user_id
 order by modified desc limit 140,140

Here's the output of EXPLAIN:

+-------+--------+-----------------+-------------+---------+------------+---
---+----------------+
| table | type   | possible_keys   | key         | key_len | ref        |
rows | Extra          |
+-------+--------+-----------------+-------------+---------+------------+---
---+----------------+
| d     | const  | PRIMARY         | PRIMARY     |       4 | const      |
1 | Using filesort |
| a     | range  | forumupdate     | forumupdate |       4 | NULL       |
849 | where used     |
| b     | eq_ref | PRIMARY,user_id | PRIMARY     |       4 | a.owner_id |
1 | where used     |
| c     | eq_ref | PRIMARY,user_id | PRIMARY     |       4 | a.reply_id |
1 | where used     |
+-------+--------+-----------------+-------------+---------+------------+---
---+----------------+





---------------------------------------------------------------------
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

Reply via email to