Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Speeding up the DBI

by tantarbobus (Hermit)
on Jul 14, 2003 at 19:32 UTC ( #274121=note: print w/replies, xml ) Need Help??


in reply to Re: Speeding up the DBI
in thread Speeding up the DBI

Yes it is. DBD::mysql behaves in the same way that DBD::Pg does when it comes to pulling all of the rows from the database server.

If you want DBD::mysql to act as if it were using cursors, you can specify mysql_use_rows on the statement handle, and then it will not pull over the whole data set on execute.

For DBD::Pg, you can declare a cursor and then execute the fetch in a loop until you have recieved all of the data. Admittedly this coould be done in a cleaner fashion where prepare could take an attribute and if prepare sees that attribute it will declare a cursor and rewrite your statement to use the cursor (which is what Pg::Simple does,IIRC)

Replies are listed 'Best First'.
Re: Re: Re: Speeding up the DBI
by diotalevi (Canon) on Jul 14, 2003 at 19:39 UTC

    I had been under the impression that cursors don't work through DBD::Pg. I'm mistaken?

      $dbh->do(q{DECLARE imprecator CURSOR FOR SELECT * FROM tablename}) ; my $number = 10; my $fetch = $dbh->prepare(q{FETCH $number FROM imprecator}); ## ### Fetch first $number * 10 rows. ## while ($fetch->execute()) { Data::Dumper::Dumper($fetch->fetchall_arrayref()); last if $fetch->rows() < $number; }
      Note: The code above has not been tested; it is for illustrative purposes only.
Re^3: Speeding up the DBI
by Anonymous Monk on Sep 04, 2013 at 18:44 UTC
    If you want DBD::mysql to act as if it were using cursors, you can specify mysql_use_rows on the statement handle, and then it will not pull over the whole data set on execute.
    I think you meant "mysql_use_result", some grief and head banging over that typo, so hopefully that'll help some wanderer around here also trying to speed up $sth->execute

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://274121]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2019-08-18 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (134 votes). Check out past polls.

    Notices?