From: Tom Lane <tgl@sss.pgh.pa.us>
To: Raj Shooj-Q16466 <shooj@motorola.com>
Cc: 'pgsql-odbc@postgresql.org' <pgsql-odbc@postgresql.org>
Subject: Re: Limiting the number of records in Execute Query
Date: Fri, 12 Sep 2003 10:24:05 -0400
Message-ID: <10820.1063376645@sss.pgh.pa.us> (raw)
In-Reply-To: <653138C25D8AD6118292000347080A370635B9C1@zin05exm02.corp.mot.com>
References: <653138C25D8AD6118292000347080A370635B9C1@zin05exm02.corp.mot.com>
Raj Shooj-Q16466 <shooj@motorola.com> writes:
> I am retrieving 1 million records by executing the sql query
> SELECT * FROM myTable ORDER BY sub_id LIMIT 20000 OFFSET <num>;
> in a loop, incrementing <num> every time by 20000.
Wouldn't it be better to use a cursor?
BEGIN;
DECLARE c CURSOR FOR SELECT * FROM myTable ORDER BY sub_id;
FETCH 20000 FROM c;
... repeat FETCH as needed ...
COMMIT;
regards, tom lane
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-odbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, shooj@motorola.com
Subject: Re: Limiting the number of records in Execute Query
In-Reply-To: <10820.1063376645@sss.pgh.pa.us>
References: <653138C25D8AD6118292000347080A370635B9C1@zin05exm02.corp.mot.com> <10820.1063376645@sss.pgh.pa.us>
* 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