The IN and NOT IN searches (sub-queries) are not optimized in MySQL yet. You may find doing a JOIN or LEFT JOIN and filtering out NULL entries to be faster. I don't know where you getting your ids not to match from, so I can't really give you a good example.

On Feb 4, 2004, at 11:04 PM, Mark wrote:

// This is where it slows things down by creating a huge list of ids NOT
to match


Step 3:
SELECT m.id, m.title
FROM movies m, movie_subcat s
WHERE s.movie = m.id
AND m.release < NOW()
[AND m.id NOT IN (huge list of ids NOT to match)]
[AND s.subcategory IN (list of 5 subcats)]
GROUP BY m.id
ORDER BY RAND()
LIMIT 5

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to