Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^7: Forking and shelling out to curl

by Corion (Pope)
on Jan 11, 2020 at 08:04 UTC ( #11111318=note: print w/replies, xml ) Need Help??


in reply to Re^6: Forking and shelling out to curl
in thread Forking and shelling out to curl

DBI can (somewhat) page data, but of course you can only page forward. The following code fetches the results in batches of 10k rows:

my $rows = []; # cache for batches of rows while( my $row = ( shift(@$rows) || # get row from cache, or reload +cache: shift(@{$rows=$sth->fetchall_arrayref(undef,10_00 +0)||[]}) ) ) { # do processing of row here ... }

Of course, just because you're transferring the data from the DB driver to Perl space in batches of 10k doesn't mean that the database driver doesn't fetch all available rows onto your machine already.

Data::Stream::Bulk wraps this approach in an(other) API, but I never got warm with it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-06-02 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (12 votes). Check out past polls.

    Notices?