Slow query

From: Date: Wed, 23 Jul 2008 07:07:06 +0000
Subject: Slow query
Groups: php.db 
Request: Send a blank email to php-db+get-45154@lists.php.net to get a copy of this message
Hi all, Below is the query we are getting a slow response on ... 2seconds ... with 4 records we were hoping to get it much quicker. Can someone advise if i can optimise this? SELECT s.movie_id, m.movie_name, movie_shortname, image_name, image_extension, m.trailerAvail FROM sessions AS s LEFT JOIN movies_information AS mi ON mi.movie_id = s.movie_id LEFT JOIN movies AS m ON m.movie_id = s.movie_id WHERE DATE( date_time ) <= ( DATE_ADD( NOW( ) , INTERVAL 21 DAY ) ) AND image_name != '' GROUP BY s.movie_id ORDER BY RAND( ) LIMIT 4; Showing rows 0 - 3 (4 total, Query took 2.4823 sec) Explain SQL returns this; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE mi ALL NULL NULL NULL NULL 104 Using where; Using temporary; Using filesort 1 SIMPLE s ALL NULL NULL NULL NULL 3690 Using where 1 SIMPLE m ALL NULL NULL NULL NULL 298 Thanks Steven

« previous php.db (#45154) next »