You are here: Re: [PHP] How to find random records in a subset? « PHP « IT news, forums, messages
Re: [PHP] How to find random records in a subset?

Posted by "Kristen G. Thorson" on 06/03/05 16:31

Try using a temporary table. It should be pretty fast. You'd do
something like

1. Select from table1 according to search criteria
2. Insert data from #1 into temp_table1
3. Random selection from temp_table1


kgt



Brian Dunning wrote:

> I am using a routine to find 50 random records in a large MySQL
> database (about a million records) where I generate a list of 50
> random unique ID's, and then use MySQL's "in" command to find them. I
> can't use "order by rand()" due to its performance hit.
>
> But I have to take it one more step: I want to first limit my found
> set to those matching a different search criteria, and then find 50
> of those.
>
> Anyone? Can this be done all within MySQL, or is it going to require
> some humongo PHP arrays?
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация