Closed (fixed)
Project:
Drupal core
Version:
5.x-dev
Component:
upload.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Jun 2006 at 16:36 UTC
Updated:
14 Dec 2006 at 02:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
magico commentedIs this being address in the current HEAD mysql optimizations?
Comment #2
magico commentedVerified (in HEAD) that the table is the same, and because I've saw some code using the where clause "nid = %d" I think we should take a better look into this optimization.
Comment #3
mr700 commentedI would say it's a verry 'easy fix'. Some rough nubers from my tests today. I was loading series of 30 nodes nodes (~ 36000 total), most with 2, some with 1 attached file (60010 images total). Without indexes it took 5-7 seconds. After
ALTER TABLE files add KEY `nid` (`nid`); ALTER TABLE file_revisions add KEY `vid` (`vid`);- always for less than a second. For large sites this can be critical.Comment #4
pwolanin commentedThe current HEAD (5.x) version of these tables define vid as a key for file_revisions, but does not include nid as an index for the files table.
So, a quick grep turns up these 2 problematic queries in 5.x:
modules/upload/upload.module:600: return db_result(db_query('SELECT SUM(filesize) FROM {files} f INNER JOIN {node} n ON f.nid = n.nid WHERE n.uid = %d', $uid));
modules/upload/upload.module:726: $result = db_query('SELECT * FROM {files} WHERE nid = %d', $node->nid);
patch for 5.x attached which adds this additional index.
Comment #5
drummEverywhere else, vid is used rather than nid.
modules/upload/upload.module:600: return db_result(db_query('SELECT SUM(filesize) FROM {files} f INNER JOIN {node} n ON f.nid = n.nid WHERE n.uid = %d', $uid));
This looks like it could easily use vid.
modules/upload/upload.module:726: $result = db_query('SELECT * FROM {files} WHERE nid = %d', $node->nid);
This might want to stay the same. It is deleting so, I'm not too worried about it.
Comment #6
pwolanin commentedThe table {files} does not have vid as a column...
patch still applies with offset- patch against current HEAD attached.
Comment #7
drummCommitted to HEAD.
Comment #8
(not verified) commented