Re: Optimising MySQL queries against huge databases?
From: Henk Verhoeven (news_at_phppeanutsREMOVE-THIS.org)
Date: 11/12/04
- Next message: Mike Wilcox: "Re: Missing something in passing form variables"
- Previous message: denisb: "Re: Missing something in passing form variables"
- In reply to:(deleted message) Michael Vilain
: "Re: Optimising MySQL queries against huge databases?" - Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 12 Nov 2004 17:59:14 +0100
Hi Jasper,
I agree with Michael about the explain, but i did not try that, so the
following are just guesses:
- there is no index on movies.image so mySQL must sequentially search
throuhg all movies that have a director (probably all or close to all 141000
- there are probably MANY movies that have an image and a director.
Unless MySQL has a special optimization for ORDER BY RAND() LIMIT ..
it may have to random-sort all of them. That will take quite some time,
i guess. So if an index on movies.image does not help, you may have to
add AND id = RAND() to the SELECT condition, with the RAND function
parameterized or multiplied and rounded or floored to get whole numbers
between the lowest and highest id in the database. And then repeat the
query until it does return a row. (if many rows have been removed you
may have to pack the id's of movies)
Success,
Henk Verhoeven,
www.phpPeanuts.org.
- Next message: Mike Wilcox: "Re: Missing something in passing form variables"
- Previous message: denisb: "Re: Missing something in passing form variables"
- In reply to:(deleted message) Michael Vilain
: "Re: Optimising MySQL queries against huge databases?" - Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|