Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Re: It's bad manners to slurp

by tantarbobus (Hermit)
on Apr 29, 2004 at 16:50 UTC ( #349188=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: It's bad manners to slurp
in thread It's bad manners to slurp

It is possible to change this behaviour with both DBD::mysql and DBD::pg For DBD::mysql you can give prepare {mysql_use_result => 1}. But be aware that by doing this, you change the behaviour of the rows() method. And for DBD::pg you can use cursors:
$db->do("declare imprecator CURSOR FOR select * from test"); $c = $db->prepare("FETCH 100 FROM imprecator") for (1..10) { # I have a more robust example somewhere $c->execute(); print Data::Dumper::Dumper($c->fetchall_arrayref()) }
It would probably be possible to encode this in the driver so you could pass an attribute to prepare {pg_use_cursor =>1}.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: It's bad manners to slurp
by eserte (Deacon) on Apr 29, 2004 at 17:12 UTC
    Another way for simple queries with MySQL 4.x is to use the HANDLER statement.
    HANDLER table OPEN; HANDLER table READ FIRST; HANDLER table READ NEXT;
      Care to elaborate? I'm unfamiliar with HANDLER.

      -sam

        It's some kind of low-level SELECT. You can't do complex queries or joins with HANDLER. You can just walk the table from the beginning to the end, optionally by using simple restrictions like > or =. The result of a "HANDLER READ" statement is a complete row, there's no way to select single rows. The advantage is speed and less memory consumption.
Re: Re: Re: Re: Re: It's bad manners to slurp
by samtregar (Abbot) on Apr 29, 2004 at 17:06 UTC
    Interesting. However, according the DBD::mysql docs mysql_use_result "tends to block other processes." I'm not sure what that means exactly but it doesn't sound good! I think I'll stick with LIMIT and OFFSET...

    -sam

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2019-10-17 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?