Closed (duplicate)
Project:
Drupal core
Version:
4.7.4
Component:
file system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2006 at 09:52 UTC
Updated:
14 Apr 2007 at 19:36 UTC
I've found a query like this:
SELECT * FROM files f INNER JOIN file_revisions r ON f.fid = r.fid WHERE r.vid = 192 ORDER BY f.fid DESC;
I'm not sure which module is executing this query.
desc SELECT * FROM files f INNER JOIN file_revisions r ON f.fid = r.fid WHERE r.vid = 192 ORDER BY f.fid DESC;
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+----------------+
| 1 | SIMPLE | f | ALL | PRIMARY | NULL | NULL | NULL | 2079 | Using filesort |
| 1 | SIMPLE | r | eq_ref | PRIMARY | PRIMARY | 8 | foolab.f.fid,const | 1 | |
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+----------------+I've added an index on file_revisions. And now MySQL can use the key.
desc SELECT * FROM files f INNER JOIN file_revisions r ON f.fid = r.fid WHERE r.vid = 192 ORDER BY f.fid DESC;
+----+-------------+-------+--------+---------------+---------+---------+--------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+---------+---------+--------------+------+----------------------------------------------+
| 1 | SIMPLE | r | ref | PRIMARY,vid | vid | 4 | const | 5 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | f | eq_ref | PRIMARY | PRIMARY | 4 | foolab.r.fid | 1 | |
+----+-------------+-------+--------+---------------+---------+---------+--------------+------+----------------------------------------------+
Comments
Comment #1
kkaefer commentedIt's upload.module on line 829 (
function upload_load()).Comment #2
kkaefer commentedFor Drupal 5, it returns (unpatched):
Comment #3
FiReaNGeL commentedThe key should be a compound on (vid, fid) to get rid of the filesort.
Comment #4
bdragon commentedDuplicate of http://drupal.org/node/73045