pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: Eric Chamberlain <eric.chamberlain@hotmail.com>
To: Andrew McMillan <andrew@morphoss.com>
Cc: pgsql-php@postgresql.org <pgsql-php@postgresql.org>
Subject: Re: Unbuffered queries
Date: Sun, 12 Jan 2014 21:59:01 +1300
Message-ID: <52D25955.4050909@catalyst.net.nz> (raw)
In-Reply-To: <BLU168-W111F40FD879BDC092DB4AC684B00@phx.gbl>
References: <BLU168-W6E6F9F54342A13F29A86484B10@phx.gbl>
	<1389227496.5900.128.camel@narbon.home.mcmillan.net.nz>
	<52CE20D5.5050700@catalyst.net.nz>
	<BLU168-W111F40FD879BDC092DB4AC684B00@phx.gbl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-php>

On 09/01/14 18:33, Eric Chamberlain wrote:
> Correct. I ended up limiting the number of records I query at a time.
> I'm not sure how much of the thread has been e-mailed to you but I have
> an example that shows the method in which I was able to query N number
> of records every iteration.
>

Unfortunately I don't seem to have seen that message. However that 
reminds me that for completeness I should really show an example 
fetching >1 row at a time in PDO (pgbench schema again):

     $fetch_num = 100;
     $cursql = "DECLARE cur1 CURSOR FOR SELECT * FROM pgbench_accounts 
WHERE bid = ?";
     $sql    = "FETCH $fetch_num FROM cur1";

     $dbh->beginTransaction();
     $curstmt = $dbh->prepare($cursql);
     $curstmt->execute(array(rand(0, 100)));

     for (;;) {
         $stmt = $dbh->prepare($sql);
         $stmt->execute();
         $rowarray = $stmt->fetchAll(PDO::FETCH_ASSOC);
         if ($rowarray) {
             foreach ($rowarray as $row) {
                 print "... " . $row['aid'] . " " . $row['bid'] . "\n";
             }
         } else {
             break;
         }
     }


Regards

Mark


-- 
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php



view thread (5+ messages)

Message-ID: <52D25955.4050909@catalyst.net.nz>
Permalink:  ../52D25955.4050909@catalyst.net.nz/
Also on:    postgresql.org/message-id/52D25955.4050909@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: mark.kirkwood@catalyst.net.nz, eric.chamberlain@hotmail.com, andrew@morphoss.com
  Subject: Re: Unbuffered queries
  In-Reply-To: <52D25955.4050909@catalyst.net.nz>
  References: <BLU168-W6E6F9F54342A13F29A86484B10@phx.gbl> <1389227496.5900.128.camel@narbon.home.mcmillan.net.nz> <52CE20D5.5050700@catalyst.net.nz> <BLU168-W111F40FD879BDC092DB4AC684B00@phx.gbl> <52D25955.4050909@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox