pg.ddx.io pgsql-php@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: vinny <vinny@xs4all.nl>
To: Thom Brown <thombrown@gmail.com>
Cc: AI Rumman <rummandba@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: large resultset
Date: Tue, 15 Jun 2010 11:40:11 +0200
Message-ID: <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> (raw)
In-Reply-To: <AANLkTimP7qSASY3dRA09p6e35CzRLo8pOyZ6J5_5Bisx@mail.gmail.com>
References: <AANLkTinXSz6PsoTyPhryAHsN3V-M0v-m3sTCLTJSJttO@mail.gmail.com>
<AANLkTimP7qSASY3dRA09p6e35CzRLo8pOyZ6J5_5Bisx@mail.gmail.com>
On Tue, 15 Jun 2010 10:33:05 +0100, Thom Brown <thombrown@gmail.com>
wrote:
> On 15 June 2010 09:31, AI Rumman wrote:
> How to return large resutlset (almost 2 millions record) in php?
>
> Presumably this is so people can download results rather than display
> them in a browser?
>
> Here's a basic a raw version of what you can do:
>
> $db = pg_connect($connection_string);
>
> $results = pg_query($db, $query);
>
> while ($result = pg_fetch_array($results)
> {
> echo implode("|", $result) . "n";
> }
>
> pg_close($db);
>
> Obviously that wouldn't do by itself, but it's quite simple to loop over
> a result set.
>
> Regards
>
> Thom
>
If that's the case surely you'd use some SQL to merge the data into one
long string and return it in a single record.
Looping over two million results is going to take a while, not to mention
quite a bit of memory.
v.
view thread (14+ messages) latest in thread
Message-ID: <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> Permalink: ../8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl/ Also on: postgresql.org/message-id/8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl ·
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: vinny@xs4all.nl, thombrown@gmail.com, rummandba@gmail.com Subject: Re: large resultset In-Reply-To: <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> References: <AANLkTinXSz6PsoTyPhryAHsN3V-M0v-m3sTCLTJSJttO@mail.gmail.com> <AANLkTimP7qSASY3dRA09p6e35CzRLo8pOyZ6J5_5Bisx@mail.gmail.com> <8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl> * 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