#361 v4.0.2 Random Media fails

closed-wont-fix
None
5
2006-10-30
2006-10-30
vince-br549
No

when attempting to customize the welcome page
with Random Media I get an error.
Postgresql v8.1 does not have a RAND() function
instead it has a
RANDOM() function.

Also Jay Pipes (Jay@mysql.com) The north american
rep for mysql
gave a performance session and explains that this
is very bad sql. He gave an example
for mysql instead of
select * from Ads order by rand();

Instead use:
select @row_id := count(*) from ads;
select @row_id := floor(rand() * @row_id) +1;
select * from ads where adid=@row_id;

If I remember correctly, he said the first bad example
has to search the db once for each row.

it doesn't appear that this will work in postgresql
He suggests using the php rand function instead.

probably something like
select count(*) from ....
get the answer, then use the
php rand function.

see his presentation @
http://jpipes.com/presentations/mysql_perf_tuning.pdf

Discussion

  • Gerry Kroll

    Gerry Kroll - 2006-10-30
    • assigned_to: nobody --> canajun2eh
    • status: open --> closed-wont-fix
     
  • Gerry Kroll

    Gerry Kroll - 2006-10-30

    Logged In: YES
    user_id=1198414

    We're not going to do anything about this in version 4.0.x.

    Media handling has been changed/improved again in PGV 4.1.
    In this version, the Random Media block is created from a
    randomly generated Media Object ID. The new code checks the
    media object's visibility using Privacy checks and if its
    display isn't permitted, the code tries again a limited
    number of times.

    The new code can't be retro-fitted to PGV 4.0.x.

     

Log in to post a comment.