| From: | Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | David Rowley <dgrowleyml(at)gmail(dot)com> |
| Subject: | Table Function Scan can report incorrect "Maximum Storage" in EXPLAIN |
| Date: | 2026-10-04 14:52:21 |
| Message-ID: | CAHza6qdXjcqXv2aGU7OCakG0OmEsy9-jfP0Gpe2EL+k-AidOhw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
40708acd65 added memory/disk usage to EXPLAIN ANALYZE for Table Function
Scan nodes. However, when the node is rescanned with changed
parameters, ExecReScanTableFuncScan() calls tuplestore_end(), so the
statistics of the earlier rescans are lost and only those of the final
rescan are reported.
This is the same problem that David reported for Material nodes in [1],
as also mentioned in [2].
For example:
EXPLAIN ANALYZE
SELECT count(*)
FROM (VALUES ((SELECT jsonb_agg(g) FROM generate_series(1, 100000) g)),
('[1]'::jsonb)) v(j),
LATERAL JSON_TABLE(v.j, '$[*]' COLUMNS (x int PATH '$')) jt;
The Table Function Scan node reports the following:
larger document first: master Memory 17kB patched Disk 4096kB
smaller document first: master Disk 4096kB patched Disk 4096kB
Regards,
Tatsuya Kawata
[1]
https://www.postgresql.org/message-id/flat/CAApHDvoa55vcRth05Ozu5be4FawgTH-aCsZ5%3DZ%2B_UXTUzUxdQg%40mail.gmail.com
[2]
https://www.postgresql.org/message-id/CAApHDvoFPyT10sRDY%2BbH1MOwHwWNnBQKR7xgEePDke15-EkMkQ%40mail.gmail.com
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Use-tuplestore_clear-instead-of-tuplestore_end-in-nodeTableFuncscan.c.patch | application/octet-stream | 4.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-10-04 14:59:02 | Re: Silence -fsanitize=function where we cast function pointers on purpose |
| Previous Message | Vlada Pogozhelskaya | 2026-10-04 14:07:23 | Re: Vacuum statistics |