MySQL Forums :: General :: search for query that result one random url from domain


Advanced Search

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 Bernd Meier 12/03/2011 07:52PM
Re: search for query that result one random url from domain Bernd Meier 12/04/2011 04:04PM
Re: search for query that result one random url from domain laptop alias 12/05/2011 05:39AM
Re: search for query that result one random url from domain Bernd Meier 12/05/2011 06:42AM
Re: search for query that result one random url from domain laptop alias 12/05/2011 07:55AM
Re: search for query that result one random url from domain Bernd Meier 12/05/2011 04:06PM
Re: search for query that result one random url from domain laptop alias 12/05/2011 06:28PM
Re: search for query that result one random url from domain Bernd Meier 12/05/2011 07:08PM
Re: search for query that result one random url from domain Rick James 12/06/2011 11:59PM
Re: search for query that result one random url from domain laptop alias 12/07/2011 03:24AM
Re: search for query that result one random url from domain Bernd Meier 12/08/2011 08:56PM
Re: search for query that result one random url from domain Rick James 12/08/2011 10:02PM
Re: search for query that result one random url from domain Bernd Meier 12/09/2011 05:31AM
Re: search for query that result one random url from domain laptop alias 12/09/2011 01:53AM
Re: search for query that result one random url from domain Bernd Meier 12/09/2011 04:42AM
Re: search for query that result one random url from domain laptop alias 12/09/2011 06:31AM
Re: search for query that result one random url from domain defor rest 12/09/2011 07:08AM


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.