Re: Re: using rand()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I guess so, but I dont think the difference would be all that great using
rand() in php or "order by rand" in mysql..
worth checking up for "programmer show off" rights anyway :-)

Cheers,
Ryan


> i guess a good question would be which one of these methods has more
>
> overhead - having php calculate the random numbers for queries, or
>
> having the mysql db pick them at random itself? i don't really focus
> that much on optimization, but if you expect heavy traffic on your
> site, it might be in your best interest to find out which one executes
> quicker.
>
>
> On Apr 8, 2005 9:41 AM, kyriacos sakkas <kyriacos@xxxxxxxxxxxxxxx> wrote:
> > first I would suggest you get the largest value from the auto increment
> > field (maybe use last_insert_id()). Then use rand(1,$cno_max) three
> > times to get three random cno numbers, then "select ... from ... where
> > cno=$val1 or cno=$val2 or cno=$val3"  should return the three values.
> > rand() can also be directly in the sql statement.
> > Also manual suggests using mt_rand instead of rand for better
performance.
> >
> > K.Sakkas
> >
> >
> > Ryan A wrote:
> > > Hey,
> > > need some advise on what would be the best way to do this:
> > >
> > > I have a table with these fields:
> > > cno (just a auto_increment field),
> > > username,
> > > sex (2 values: man, woman),
> > > has_pic (0=no,1=yes),



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux