I need a fast query for this table:
id|url|domain
example:
ID URL Domain
1 http://www.google.de/example1 http://www.google.de
2 http://www.google.de/example2 http://www.google.de
3 http://www.google.de/example3 http://www.google.de
4 http://www.yahoo.de/example1 http://www.yahoo.de
5 http://www.yahoo.de/example1 http://www.yahoo.de
6 http://www.yahoo.de/example1 http://www.yahoo.de
The table contains 1 millions rows...so a query should return a respond very fast..
for example i like to get 1000 unique random urls without having duplicate domains in it....
i tried something like:
SELECT x.*
FROM ( SELECT *
FROM table
ORDER BY RAND() ) x
GROUP BY domain LIMIT 1000
but it takes 1 minute to gave me some results...thats too time consuming
table structure is myisam, but could be converted to anything else if i got faster results
need some help
thank you
i just get 10 random urls but takes about 50 seconds.....
– user1082391 Dec 05 '11 at 23:09