On Sat, Jun 25, 2011 at 11:20 PM, bob <aj...@hotmail.com> wrote:
> i'm getting an issue relating to the use of the random() function in a
> SQL query.
>
> i run 2 PHP scripts very quickly (less than 1 second apart).
>
> they use an SQL query like    SELECT * FROM table ORDER BY random() LIMIT 5;
>
> because the 2 scripts run so close together (in time)  i get the same
> values as a result.


Since sqlite initialize the seed only once you probably mean the case
when your two queries used on separately opened and closed
connections, right?

I tried to simulate this with a test table containing numbers from 1
to 5 and query Select value from testtable order by random(). Sqlite
gave different results most of the times. This was on a windows
machine where the time between connection was more than 1ms and also
on a machine when the time was < 1 ms. My tests can be wrong if sqlite
initializes the seed once for the library, not for single connection.
I tried to track this with loading sqlite dll for every connection,
but unfortunately I could not find a windows machine that can do all
these tasks in less than a 1 ms. But for tests > 1 ms the numbers were
still different

So you probably have to look in a different layer

Max
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to