Hi,
I have a query which appears in the slow logs.
The query is a simple order by id query:
SELECT news_id,news_title FROM news ORDER BY news_id DESC LIMIT 25
Explain:
explain SELECT news_id,news_title FROM news ORDER BY news_id DESC LIMIT 25;
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| 1 | SIMPLE | news | index | NULL | PRIMARY | 4 | NULL | 179016 | |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
1 row in set (0.00 sec)
I've tried "FORCE INDEX(PRIMARY)" but nothing changed:
explain SELECT news_id,news_title FROM news FORCE INDEX(PRIMARY) ORDER BY news_id DESC LIMIT 25;
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| 1 | SIMPLE | news | index | NULL | PRIMARY | 4 | NULL | 179016 | |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
1 row in set (0.00 sec)
This is a MyISAM table and news_id is primary key for the table.
How can i optimise this query?
I have a query which appears in the slow logs.
The query is a simple order by id query:
SELECT news_id,news_title FROM news ORDER BY news_id DESC LIMIT 25
Explain:
explain SELECT news_id,news_title FROM news ORDER BY news_id DESC LIMIT 25;
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| 1 | SIMPLE | news | index | NULL | PRIMARY | 4 | NULL | 179016 | |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
1 row in set (0.00 sec)
I've tried "FORCE INDEX(PRIMARY)" but nothing changed:
explain SELECT news_id,news_title FROM news FORCE INDEX(PRIMARY) ORDER BY news_id DESC LIMIT 25;
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
| 1 | SIMPLE | news | index | NULL | PRIMARY | 4 | NULL | 179016 | |
+----+-------------+-------+-------+---------------+-------- -+---------+------+--------+-------+
1 row in set (0.00 sec)
This is a MyISAM table and news_id is primary key for the table.
How can i optimise this query?
Comment