I have an SQL query that sometimes (but certainly not always) appears in my slow query log, and I'm not sure how it can be optimized. Can anyone offer some tips?
Code:
mysql> explain select max(timestamp) as timestamp, dcdate, px_feeds.id from px_items, px_feeds where px_items.feed_id = px_feeds.id and in_blogroll = '1' and username = 'XXX' group by px_feeds.id order by timestamp;
+----+-------------+----------+------+----------------+-------------+---------+-------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+----------------+-------------+---------+-------------------------+------+----------------------------------------------+
| 1 | SIMPLE | px_feeds | ALL | PRIMARY,id_idx | NULL | NULL | NULL | 260 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | px_items | ref | feed_id_idx | feed_id_idx | 4 | mikeage_fof.px_feeds.id | 145 | |
+----+-------------+----------+------+----------------+-------------+---------+-------------------------+------+----------------------------------------------+
My slow query log often says things like:
Code:
# Time: 081019 8:28:41
# User@Host: mikeage_fof[mikeage_fof] @ localhost []
# Query_time: 22 Lock_time: 0 Rows_sent: 71 Rows_examined: 10363
use mikeage_fof;
select max(timestamp) as timestamp, dcdate,
px_feeds.id from px_items, px_feeds where
px_items.feed_id = px_feeds.id and in_blogroll = '1' and
username = 'XXX' group
by px_feeds.id order by timestamp;