I want to get random average price of 300 products but guess what, I can't
1 - First ORDER BY RAND does not use the index. EXPLAIN told me it searches 11 million records. That wouldn't be sane would it? So what is the right way of doing this?
2 - I got busted again! I made attempt to be creative and run a fancy query butCode:#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'Code:SELECT AVG(price) FROM products WHERE id IN (SELECT id FROM products_table ORDER BY RAND( ) LIMIT 300 )