Re: Limiting the number of records in Execute Query - Mailing list pgsql-odbc

From Tom Lane
Subject Re: Limiting the number of records in Execute Query
Date
Msg-id 10820.1063376645@sss.pgh.pa.us
Whole thread Raw
In response to Limiting the number of records in Execute Query  (Raj Shooj-Q16466 <shooj@motorola.com>)
List pgsql-odbc
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

pgsql-odbc by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: visual basic
Next
From: "Greg Campbell"
Date:
Subject: ADO Server Cursors and OID