Table Function Scan can report incorrect "Maximum Storage" in EXPLAIN - Mailing list pgsql-hackers

From Tatsuya Kawata
Subject Table Function Scan can report incorrect "Maximum Storage" in EXPLAIN
Date
Msg-id CAHza6qdXjcqXv2aGU7OCakG0OmEsy9-jfP0Gpe2EL+k-AidOhw@mail.gmail.com
Whole thread
Responses Re: Table Function Scan can report incorrect "Maximum Storage" in EXPLAIN
List 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

pgsql-hackers by date:

Previous
From: Vlada Pogozhelskaya
Date:
Subject: Re: Vacuum statistics
Next
From: Peter Eisentraut
Date:
Subject: Re: Silence -fsanitize=function where we cast function pointers on purpose