Re: pg_plan_advice

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_plan_advice
Date: 2026-03-18 20:44:34
Message-ID: 1057602.1773866674@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Don't know if you noticed yet, but avocet has shown [1] that one
pg_plan_advice test case is unstable under debug_discard_caches = 1:

diff -U3 /home/buildfarm/avocet/buildroot/HEAD/pgsql.build/contrib/pg_plan_advice/expected/prepared.out /home/buildfarm/avocet/buildroot/HEAD/pgsql.build/contrib/pg_plan_advice/results/prepared.out
--- /home/buildfarm/avocet/buildroot/HEAD/pgsql.build/contrib/pg_plan_advice/expected/prepared.out 2026-03-16 11:04:23.453026641 +0100
+++ /home/buildfarm/avocet/buildroot/HEAD/pgsql.build/contrib/pg_plan_advice/results/prepared.out 2026-03-17 20:42:16.262657929 +0100
@@ -57,11 +57,13 @@
-- Prepared, but always_store_advice_details = true, so should show feedback.
PREPARE pt4 AS SELECT * FROM ptab;
EXPLAIN (COSTS OFF, PLAN_ADVICE) EXECUTE pt2;
- QUERY PLAN
-------------------------
+ QUERY PLAN
+--------------------------------
Seq Scan on ptab
+ Supplied Plan Advice:
+ SEQ_SCAN(ptab) /* matched */
Generated Plan Advice:
SEQ_SCAN(ptab)
NO_GATHER(ptab)
-(4 rows)
+(6 rows)

I can reproduce this pretty trivially by adding
SET debug_discard_caches = 1;
at the top of contrib/pg_plan_advice/sql/prepared.sql.

It looks like the appearance of "Supplied Plan Advice:" depends
on whether the prepared query's plan got regenerated or not.
I'm not sure if this represents a bug (ie undesirable behavior) or
it's just that the test is being insufficiently careful about
being reproducible.

regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=avocet&dt=2026-03-16%2010%3A03%3A01

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-03-18 20:49:37 Re: Stack-based tracking of per-node WAL/buffer usage
Previous Message Zsolt Parragi 2026-03-18 20:20:20 Re: table AM option passing