Hi!

I got a very simple SQL query which takes 0.2sec to execute (far too
long) and it seems I can't do nothing about it.

I use :

"SELECT id FROM news WHERE state=1 and main_page=1 order by timestamp desc LIMIT 10"

I got indexes too :

+-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+---------+
| Table | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | 
|Cardinality | Sub_part | Packed | Comment |
+-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+---------+
| news  |          0 | PRIMARY    |            1 | id          | A         |        
|8433 |     NULL | NULL   |         |
| news  |          1 | state      |            1 | state       | A         |           
|4 |     NULL | NULL   |         |
| news  |          1 | main_page  |            1 | main_page   | A         |           
|1 |     NULL | NULL   |         |
| news  |          1 | timestamp  |            1 | timestamp   | A         |          
|22 |     NULL | NULL   |         |
| news  |          1 | main_page2 |            1 | main_page   | A         |           
|1 |     NULL | NULL   |         |
| news  |          1 | main_page2 |            2 | state       | A         |           
|6 |     NULL | NULL   |         |
| news  |          1 | main_page2 |            3 | timestamp   | A         |          
|68 |     NULL | NULL   |         |
+-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+---------+

I did read the doc and I understood this is slow because I use the ORDER
BY, but isn't it a way to speed this up a little bit ?

Thanks.

-- 
Fabien Penso <[EMAIL PROTECTED]> | LinuxFr a toujours besoin de :
http://perso.LinuxFr.org/penso/  | http://linuxFr.org/dons/


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