pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedLimiting the number of records in Execute Query
3+ messages / 2 participants
[nested] [flat]
* Limiting the number of records in Execute Query
@ 2003-09-12 11:11 Raj Shooj-Q16466 <shooj@motorola.com>
0 siblings, 0 replies; 3+ messages in thread
From: Raj Shooj-Q16466 @ 2003-09-12 11:11 UTC (permalink / raw)
To: pgsql-odbc
Hello,
I would like to know how to retrieve large amount of records in small segments.
I am retrieving 1 million records by executing the sql query
SELECT * FROM myTable ORDER BY sub_id LIMIT 1000 OFFSET <num>;
in a loop, incrementing <num> every time by 1000.
Is there any sql-odbc api which does the same(a variant of SQLExecute)? An api which enables to scroll along the records and execute the query?
Thanks,
Shooj.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Limiting the number of records in Execute Query
@ 2003-09-12 12:19 Raj Shooj-Q16466 <shooj@motorola.com>
2003-09-12 14:24 ` Re: Limiting the number of records in Execute Query Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Raj Shooj-Q16466 @ 2003-09-12 12:19 UTC (permalink / raw)
To: pgsql-odbc
Hello,
I would like to know how to retrieve large amount of records in small segments.
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.
This is working fine, but the speed of execution is slow (may be due to the ORDER BY that is done each time.)
Is there any sql-odbc api which does the same(a variant of SQLExecute)?
An api which enables to scroll along the records and execute the query?
Thanks,
Shooj.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Limiting the number of records in Execute Query
2003-09-12 12:19 Limiting the number of records in Execute Query Raj Shooj-Q16466 <shooj@motorola.com>
@ 2003-09-12 14:24 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2003-09-12 14:24 UTC (permalink / raw)
To: Raj Shooj-Q16466 <shooj@motorola.com>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-09-12 14:24 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-12 11:11 Limiting the number of records in Execute Query Raj Shooj-Q16466 <shooj@motorola.com>
2003-09-12 12:19 Limiting the number of records in Execute Query Raj Shooj-Q16466 <shooj@motorola.com>
2003-09-12 14:24 ` Tom Lane <tgl@sss.pgh.pa.us>
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