Skip site navigation (1) Skip section navigation (2)

Re: large resultset

From: AI Rumman <rummandba(at)gmail(dot)com>
To: Thom Brown <thombrown(at)gmail(dot)com>
Cc: vinny <vinny(at)xs4all(dot)nl>, pgsql-php(at)postgresql(dot)org
Subject: Re: large resultset
Date: 2010-06-15 10:01:17
Message-ID: AANLkTinfQIZXAcJE6GBD6P1AsOVnli9UuZDMl7BvbeHl@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-php
No. I need to send 2 million records. I want to know what is the best
possible way to send these records?
HOw should I write the plpgsql procedure to send record ony by one to
improve the response time to the users?

On Tue, Jun 15, 2010 at 3:43 PM, Thom Brown <thombrown(at)gmail(dot)com> wrote:

> On 15 June 2010 10:40, vinny <vinny(at)xs4all(dot)nl> wrote:
>
>>
>> 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"; //typo before
>>
>> > }
>> >
>> > 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.
>>
>>
> I don't understand.  Return all data as a single massive string?
>
> Thom
>

In response to

Responses

pgsql-php by date

Next:From: Raymond O'DonnellDate: 2010-06-15 10:15:31
Subject: Re: large resultset
Previous:From: Marco DieckhoffDate: 2010-06-15 09:49:57
Subject: Re: large resultset

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group