Slow query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux