MySQL Forums
Forum List  »  General

search for query that result one random url from domain
Posted by: Bernd Meier
Date: December 03, 2011 07:52PM

Hi

I need a fast query for this table:

id|url|domain

example:
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

myisam, but could be converted to anything else if i got faster results

need some help

thank you



Edited 1 time(s). Last edit at 12/03/2011 07:58PM by Bernd Meier.

Options: ReplyQuote


Subject
Written By
Posted
search for query that result one random url from domain
December 03, 2011 07:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.