> select id,name,desc,cat,date from table where cat='12'
>
> however I need to order the results by date desc... I have indexes on both
> the cat and date (of type timestamp) fields however this operation is much
> more slowly when I used the order.... So the result is something like this
>
> select id,name,desc,cat,date from table where cat='12'
> takes 0.7 seconds
>
> select id,name,desc,cat,date from table where cat='12' order by date desc
> takes 2.4 seconds
>

1. MySQL only uses one index for each table in a JOIN; this query only uses
one table, so only one index is used.
2. DESC is slower than ASC
3. Try creating an index on two columns; try cat and date, and try date and
cat.
4. Check EXPLAIN SELECT id,name...... to see whether the right index is
used.

Regards, Jigal.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to