List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:July 30 1999 4:18pm
Subject:how to emulate "cursors"
View as plain text  
>>>>> "Vivek" == Vivek Khera <khera@stripped> writes:

Vivek> I have an application where I need to select certain random values
Vivek> from a select set.  The obvious way to do it is via cursors.  That is, 
Vivek> I perform the select, generate the random numbers, then seek the
Vivek> cursor that position in the set to retrieve the row.  The data set is
Vivek> *way* big and will not fit into memory, so that's not a viable option.

Vivek> Right now, I'm doing a COUNT() on the dataset, then performing
Vivek> repetitive "SELECT ... LIMIT N,1" where N is my random number.
Vivek> Needless to say, this is very inefficient!

Vivek> Is there some good way to emulate the cursor functionality from the
Vivek> Perl DBI interface?

In MySQL 3.23.2 you can do:

SELECT * from table order by rand();

Regards,
Monty
Thread
how to emulate "cursors"Vivek Khera14 Jul
  • how to emulate "cursors"sinisa14 Jul
    • Re: how to emulate "cursors"Vivek Khera14 Jul
      • Re: how to emulate "cursors"sinisa15 Jul
  • Re: how to emulate "cursors"Orlando Andico14 Jul
    • Re: how to emulate "cursors"Vivek Khera14 Jul
      • Re: how to emulate "cursors"Orlando Andico14 Jul
  • Null columns in indexesChris Cleveland18 Jul
    • Re: Null columns in indexesPaul DuBois18 Jul
  • how to emulate "cursors"Michael Widenius30 Jul