| From: | Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com> |
|---|---|
| To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
| Cc: | dgrowleyml(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Material node can report incorrect "Maximum Storage" in EXPLAIN |
| Date: | 2026-10-04 16:07:39 |
| Message-ID: | CAHza6qdWpTFS6kG8Fyg_nWNy=izrzCHWpVoom+ReEgukjBEUJA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi David,
I reviewed v1. It applies cleanly to master (3ff475ac12e), and make
check passes.
> EXPLAIN ANALYZE
> SELECT count(*) FROM (VALUES(10000),(1)) v1(r1)
> LEFT JOIN LATERAL (
> SELECT * FROM generate_series(1, 2) gs0
> LEFT JOIN LATERAL (
> SELECT * FROM generate_series(1, v1.r1) gs1
> FULL JOIN generate_series(1, v1.r1) gs4 ON false
> ) ss on true
> ) q on true;
With your example query, I confirmed that the outer Materialize node
reports the same storage regardless of the order of the VALUES. I also
tried it with work_mem = 64kB, so that the larger rescan spills to disk.
The reported value is again the same regardless of the order, and once
the tuplestore has spilled to disk, it keeps being reported as Disk even
if a later rescan is small. LGTM.
A nit in the commit message: "the repored Material storage" should be
"reported".
> > The misreporting of the storage likely isn't a big deal. I suspect
> > rescans of Material nodes are not massively common, so maybe it's not
> > worth backpatching a fix.
>
> I have no evidence but I feel same as you (rescans of Material nodes
> are not massively common). Probably it's not worth backpatching. If we
> need backpatching, we could do it later.
As for backpatching, I agree with you and Ishii-san.
Table Function Scan has the same problem, since
ExecReScanTableFuncScan() also calls tuplestore_end(), so I've posted a
patch fixing it the same way in a separate thread [1].
Regards,
Tatsuya Kawata
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stefan Guha | 2026-10-04 16:24:49 | Planning time quadratic in the IN-list length for "c = X AND (a, b) IN (...)" with BitmapOr |
| Previous Message | Alexandre Felipe | 2026-10-04 16:06:20 | Re: Throwing away unnecessary spin-locks |