From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com> |
Subject: | Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs |
Date: | 2024-04-02 20:09:04 |
Message-ID: | b5fbba3d-2914-457e-a701-7892f86c3ea4@manitou-mail.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> I do not buy that psql's FETCH_COUNT mode is a sufficient reason
> to add it. FETCH_COUNT mode is not something you'd use
> non-interactively
I should say that I've noticed significant latency improvements with
FETCH_COUNT retrieving large resultsets, such that it would benefit
non-interactive use cases.
For instance, with the current v7 patch, a query like the OP's initial
case and batches of 1000 rows:
$ cat fetchcount-test.sql
select repeat('a', 100) || '-' ||
i || '-' || repeat('b', 500) as total_pat
from generate_series(1, 5000000) as i
\g /dev/null
$ export TIMEFORMAT=%R
$ for s in $(seq 1 10); do time /usr/local/pgsql/bin/psql -At \
-v FETCH_COUNT=1000 -f fetchcount-test.sql; done
3.597
3.413
3.362
3.612
3.377
3.416
3.346
3.368
3.504
3.413
=> Average elapsed time = 3.44s
Now without FETCH_COUNT, fetching the 5 million rows in one resultset:
$ for s in $(seq 1 10); do time /usr/local/pgsql/bin/psql -At \
-f fetchcount-test.sql; done
4.200
4.178
4.200
4.169
4.195
4.217
4.197
4.234
4.225
4.242
=> Average elapsed time = 4.20s
By comparison the unpatched version (cursor-based method)
gives these execution times with FETCH_COUNT=1000:
4.458
4.448
4.476
4.455
4.450
4.466
4.395
4.429
4.387
4.473
=> Average elapsed time = 4.43s
Now that's just one test, but don't these numbers look good?
Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-04-02 20:13:23 | Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs |
Previous Message | Regina Obe | 2024-04-02 19:58:36 | RE: Crash on UNION with PG 17 |