Re: pg_plan_advice

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Jakub Wartak <jakub.wartak@enterprisedb.com>
Cc: Lukas Fittl <lukas@fittl.com>, Jacob Champion <jacob.champion@enterprisedb.com>, Dian Fay <di@nmfay.com>, Matheus Alcantara <matheusssilv97@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-15T14:40:49Z
Lists: pgsql-hackers

Attachments

On Thu, Jan 15, 2026 at 7:28 AM Jakub Wartak
<jakub.wartak@enterprisedb.com> wrote:
> The last one seems to pass all my tests (with already provided fixup
> from yesterday), but I'm absolutely not sure if that's the proper way to
> address that).

Thanks. I don't think that's the right fix but the analysis was very
helpful to me in understanding the problem. I think the issue is that
the previous code was confusing "need to generate an advice string"
with "need to walk the plan tree". The latter is a superset of the
former, because we also need to walk the plan tree to generate advice
feedback.

So here's v10. 0001-0004 are unchanged, with the exception that in
0003, I have adjusted accumulate_append_subpath() to incorporate the
absorbed AppendPath's child_append_relid_sets into the surviving
AppendPath's child_append_relid_sets, instead of only the absorbed
AppendPath's relids proper. I don't think this makes any practical
difference to pg_plan_advice, but I might be wrong, and the old way
seems like an obvious oversight. 0005 has a bunch of small fixes,
thanks to all the review comments:

- Fixed mis-spelled Reviewed-by header for Ajay Pal.
- Added Reviewed-by header for John Naylor.
- Added modified version of the test case proposed by Jacob.
- Changed a "break" to "continue" in pgpa_occurrence_number. I don't
think this had any practical impact but it was inconsistent and
contradicted the comment.
- Added a new walk_plan_tree flag to pgpa_planner_state to avoid
getting confused about whether to build pgpa_sj_unique_rel objects.
- Don't let implicit join order constraints arising from join methord
or semijoin uniqueness advice to add to jo_permit_indexes.
- Don't consider join order advice fully matched if we only fully
matched a sublist.
- Remove pgpa_walker_get_rti and properly handle 0 return values from
pgpa_compute_rti_from_identifier instead.

I'm very appreciative to everyone for all the testing and reports
about 0005; I still do need some substantive code review particularly
of 0001.

Thanks,

-- 
Robert Haas
EDB: http://www.enterprisedb.com

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_plan_advice: Fix another unique-semijoin bug.

  2. pg_plan_advice: Export feedback-related definitions.

  3. pg_plan_advice: Fix a bug when a subquery is pruned away entirely.

  4. pg_plan_advice: Add alternatives test to Makefile.

  5. pg_plan_advice: Handle non-repeatable TABLESAMPLE scans.

  6. pg_stash_advice: Allow stashed advice to be persisted to disk.

  7. Add pg_stash_advice contrib module.

  8. pg_plan_advice: Avoid assertion failure with partitionwise aggregate.

  9. pg_plan_advice: Invent DO_NOT_SCAN(relation_identifier).

  10. Add an alternative_plan_name field to PlannerInfo.

  11. pg_plan_advice: Refactor to invent pgpa_planner_info

  12. Respect disabled_nodes in fix_alternative_subplan.

  13. get_memoize_path: Don't exit quickly when PGS_NESTLOOP_PLAIN is unset.

  14. test_plan_advice: Set TAP test priority 50 in meson.build.

  15. pg_plan_advice: Avoid a crash under GEQO.

  16. Test pg_plan_advice using a new test_plan_advice module.

  17. pg_plan_advice: Always install pg_plan_advice.h, and in the right place

  18. pg_plan_advice: Fix failures to accept identifier keywords.

  19. Add pg_plan_advice contrib module.

  20. Allow extensions to mark an individual index as disabled.

  21. Replace get_relation_info_hook with build_simple_rel_hook.

  22. Store information about Append node consolidation in the final plan.

  23. Store information about elided nodes in the final plan.

  24. Store information about range-table flattening in the final plan.

  25. Pass cursorOptions to planner_setup_hook.

  26. Fix PGS_CONSIDER_NONPARTIAL interaction with Materialize nodes.

  27. Fix mistakes in commit 4020b370f214315b8c10430301898ac21658143f

  28. Allow for plugin control over path generation strategies.

  29. Update some comments for fasthash

  30. Allow passing a pointer to GetNamedDSMSegment()'s init callback.

  31. Don't reset the pathlist of partitioned joinrels.

  32. Treat number of disabled nodes in a path as a separate cost metric.