> /* This table has 5000 rows */
> CREATE TABLE files (
>   id int(11) NOT NULL auto_increment,
>   dir_id int(11) NOT NULL default '0',
>   name varchar(100) NOT NULL default '',
>   date datetime default NULL,
>   PRIMARY KEY  (id),
>   KEY date (date)
> ) TYPE=MyISAM;
>
> for grins and giggles, add:
> key dir_id(dir_id),
> to the above.

That didn't change anything in this query (same query time, same EXPLAIN
output):

SELECT files.id, dirs.name FROM files
LEFT JOIN dirs ON files.dir_id=dirs.id
ORDER BY files.date DESC LIMIT 1;

But it actually made this query slower -- 0.07 sec instead of 0.03!

SELECT files.id, dirs.name FROM files, dirs where files.dir_id=dirs.id
ORDER BY files.date DESC LIMIT 1;

Jordan Russell


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