Re: reducing IO and memory usage: sending the content of a table to multiple files

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: reducing IO and memory usage: sending the content of a table to multiple files
Date: 2009-04-03 02:54:34
Message-ID: dcc563d10904021954w7923db0bne1df993b8b69d055@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 2, 2009 at 7:05 PM, Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
> On Thu, Apr 02, 2009 at 09:48:33PM +0200, Ivan Sergio Borgonovo wrote:
>> I didn't find any elegant example of cursor use in PHP... OK PHP is
>> not the most elegant language around... but still any good exapmle
>> someone could point me at?
>
> I don't program PHP; but my guess would be something like:
>
>  pg_query("BEGIN;");
>  pg_query("DECLARE cur CURSOR FOR SELECT * FROM t1;");
>  while (pg_num_rows($result = pg_query("FETCH 1000 FROM cur;")) > 0) {
>    while($row = pg_fetch_array($result)) {
>    }
>  }
>  pg_query("COMMIT;");

I've done something similar and it worked just fine.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message itishree sukla 2009-04-03 05:10:39 Re: [GENERAL] Hello, i want to subscribe...
Previous Message Scott Marlowe 2009-04-03 02:48:15 Re: slow select in big table