Re: large resultset

From: vinny <vinny(at)xs4all(dot)nl>
To: Thom Brown <thombrown(at)gmail(dot)com>
Cc: AI Rumman <rummandba(at)gmail(dot)com>, <pgsql-php(at)postgresql(dot)org>
Subject: Re: large resultset
Date: 2010-06-15 09:40:11
Message-ID: 8f468dc246fb6075f2a1f46b09f71a6d@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php


On Tue, 15 Jun 2010 10:33:05 +0100, Thom Brown <thombrown(at)gmail(dot)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.

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Thom Brown 2010-06-15 09:43:35 Re: large resultset
Previous Message Thom Brown 2010-06-15 09:33:05 Re: large resultset