List:General Discussion« Previous MessageNext Message »
From:Chris Knipe Date:July 20 2005 2:12pm
Subject:Re: random rows selection
View as plain text  
Put a index on col3 and it will be faster.  That's the only way as far as I 
know.

--
Chris.

----- Original Message ----- 
From: "Michael Monashev" <michael@stripped>
To: <mysql@stripped>
Sent: Wednesday, July 20, 2005 3:04 PM
Subject: random rows selection


> Hello,
>
> How to select 5 random rows from big table with WHERE clause?
>
> This query very slow on 1 mln rows:
> SELECT col1, col2 FROM table WHERE col3=123 ORDER BY RAND() LIMIT 5
>
> Have you a faster one?
>
> Sincerely,
> Michael,
> http://xoib.com/ http://3d2f.com/
> http://qaix.com/ http://ryxi.com/
> http://gyxe.com/ http://gyxu.com/
> http://xywe.com/ http://xyqe.com/
>
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
> 


Thread
random rows selectionMichael Monashev20 Jul
  • Re: random rows selectionGleb Paharenko20 Jul
    • Re: random rows selectionMichael Monashev20 Jul
      • Re: random rows selectionGleb Paharenko21 Jul
  • Re: random rows selectionChris Knipe20 Jul
  • Re: random rows selectionNuno Pereira21 Jul