Try PostgreSQL 19 pg_plan_advice from a Desktop GUI (Visual EXPLAIN, pg_stash_advice)
PostgreSQL 19 adds pg_plan_advice and pg_stash_advice so you can inspect and constrain planner choices. Try EXPLAIN (PLAN_ADVICE) and SET pg_plan_advice.advice in HiDataLinker's SQL editor, then compare plans with visual EXPLAIN ANALYZE / BUFFERS.
正文目前为英文。
PostgreSQL 19.0, announced on 19 November 2026, adds the pg_plan_advice module so you can describe, reproduce, and constrain planner choices with a plan-advice mini-language, and the companion pg_stash_advice extension to store that advice and apply it by query identifier. This guide shows how to try that official SQL from HiDataLinker, a free MIT PostgreSQL desktop GUI (MySQL in the same client): local-first credentials, a SQL editor, visual EXPLAIN with ANALYZE / BUFFERS, and no seat, tab, or connection freemium wall. These modules exist only on PostgreSQL 19+. Confirm the server with SELECT version();.
When the planner is rational — and still wrong
The planner usually picks a good plan, but it can only see the statistics it has. When those statistics go stale, a perfectly reasonable choice can become expensive. Mayur B.'s PostgreSQL 19: When the Planner Needs Adult Supervision, syndicated on Planet PostgreSQL on 23 November 2026 (18:09 UTC, 24 November 02:09 Asia/Shanghai), walks through a transactional-outbox polling query: after a large burst of un-analyzed READY rows, the planner in his capture switched from an index scan to a bitmap heap scan plus an external merge sort that spilled to temporary files. PostgreSQL 19 does not hide that class of autovacuum or statistics problem. What it adds is a way to inspect the plan the planner chose, and — carefully — to constrain the next attempt.
Official docs are blunt about the risk. Because the planner often makes good decisions, overriding it can backfire if the data distribution changes and the advice blocks a better plan. Use plan advice when the benefit of stabilizing a known-good choice outweighs that risk, and keep the advice string as small as you can.
What HiDataLinker actually ships
HiDataLinker v1.3.0 includes a SQL editor, visual EXPLAIN with optional ANALYZE and BUFFERS, a PostgreSQL workbench, Schema checkup, dump / same-engine migrate, and a top-bar switch-database control for PostgreSQL. After an extension exists on the server, it can appear in the object tree. You can paste a postgresql:// URL or DATABASE_URL, keep the profile on your machine, and run the documented statements yourself.
It does not ship a plan-advice interface, a visual PLAN_ADVICE toggle, or a stash manager. Visual EXPLAIN renders ANALYZE / BUFFERS only; it does not draw PLAN_ADVICE or the official EXPLAIN (ANALYZE, IO) options. You can still run EXPLAIN (PLAN_ADVICE) and EXPLAIN (ANALYZE, IO) as text in the SQL editor. HiDataLinker will not load modules for you, edit shared_preload_libraries or session_preload_libraries in the app, apply stashed advice automatically, or hide stale-statistics problems. Loading the module and setting advice are server or session settings, not GUI switches.
For REPACK, ON CONFLICT DO SELECT, COPY TO FORMAT json, and the visual EXPLAIN ANALYZE / BUFFERS control itself, see Try PostgreSQL 19 SQL from a Desktop GUI. This page covers only plan advice.
1. Connect to a PostgreSQL 19 server
- Install from hidatalinker.onesolo.app.
- Open New Connection — paste the URI or fill host, port, user, password, and database. See paste a DATABASE_URL.
- Test, then connect. Profiles stay on your machine — local-first, no hosted workspace.
- Run
SELECT version();and confirm you are on PostgreSQL 19+.
You need a role that can load the module (or a server already configured to preload it) and can run EXPLAIN on the query you care about.
2. Load pg_plan_advice (server or session, not a GUI toggle)
The official pg_plan_advice docs list three ways to load the module: add it to shared_preload_libraries and restart the server, add it to session_preload_libraries and start a new session, or load it into the current session with LOAD:
LOAD 'pg_plan_advice';
Run that in the SQL editor if the module is not already preloaded. There is no in-app preload editor. On a managed host, changing shared_preload_libraries usually means the provider's parameter UI or a superuser ALTER SYSTEM, then a restart — still not a HiDataLinker control.
Once the module is loaded, EXPLAIN grows a PLAN_ADVICE option.
3. Read the generated advice in the SQL editor
Use the official pattern to see the advice string for the plan the planner already chose:
EXPLAIN (COSTS OFF, PLAN_ADVICE)
SELECT * FROM join_fact f
JOIN join_dim d ON f.dim_id = d.id;
The text result includes a Generated Plan Advice block: join order, join method, scan method, and parallelism tags such as JOIN_ORDER(f d), HASH_JOIN(d), SEQ_SCAN(f d), and NO_GATHER(f d). Advice names the query alias, not a bare table name. You do not have to enforce every tag. A common approach in the docs is to keep only the constraints you actually want, for example just the join order.
This output is text in the SQL editor. Do not expect the visual EXPLAIN view to add a PLAN_ADVICE pane.
4. Constrain the next plan, then compare with visual EXPLAIN
To try that advice on the next planning cycle:
SET pg_plan_advice.advice = 'JOIN_ORDER(f d)';
EXPLAIN (COSTS OFF)
SELECT * FROM join_fact f
JOIN join_dim d ON f.dim_id = d.id;
EXPLAIN then shows Supplied Plan Advice with feedback such as /* matched */ or /* partially matched */. If you omit PLAN_ADVICE, no new advice string is generated, but the supplied advice is still listed so you can see that the plan was influenced.
For a side-by-side sense of actual runtime — scans, buffer hits, and whether a sort spilled — use the workbench Explain control. In v1.3.0 that visual plan honestly supports ANALYZE and BUFFERS only. The optional Actually run control uses EXPLAIN (ANALYZE, BUFFERS, ...) inside a transaction that is then rolled back, so writes from the analyzed statement do not persist. Sequence increments and other non-transactional side effects cannot be undone. Official EXPLAIN (ANALYZE, IO) stays in the SQL editor as text; visual EXPLAIN does not render the IO option.
Plan advice constrains the planner's choices; it does not replace the planner. You only get a plan the core planner already considered viable. Advice that asks for something impossible can produce nodes flagged Disabled: true, which may be no better — or much worse — than the unadvised plan. It also cannot currently control aggregation methods or set operations such as UNION. Prepared statements and PL/pgSQL can reuse a cached plan even after you change pg_plan_advice.advice; sessions that need a fresh plan can run DISCARD PLANS.
Mayur's outbox example uses the same session hook with a smaller string that pins an index scan, then checks EXPLAIN (ANALYZE, BUFFERS) to confirm the index path returned. The SET can also live in application code for a single session. That is still something you type or ship; HiDataLinker does not inject it.
5. Persist advice with pg_stash_advice (optional)
pg_stash_advice stores a mapping from query identifiers to advice strings in dynamic shared memory and can apply that advice automatically when a matching query is planned. Officially you need all of the following:
CREATE EXTENSION pg_stash_advicein at least one database, so the management functions exist.- The module loaded in every session that should apply stashed advice — usually by adding
pg_stash_advicetoshared_preload_librariesand restarting. That is a server setting, not an in-app toggle. compute_query_idenabled so query identifiers are computed. If it isauto, loadingpg_stash_adviceturns it on.
Then, in the SQL editor:
SELECT pg_create_advice_stash('lab_plans');
-- Query ID comes from EXPLAIN (VERBOSE, PLAN_ADVICE);
-- pg_stat_statements can also show IDs, but not advice strings.
SELECT pg_set_stashed_advice('lab_plans', 1234567890123456789, 'JOIN_ORDER(f d)');
ALTER DATABASE mydb SET pg_stash_advice.stash_name = 'lab_plans';
-- Or: ALTER ROLE app_user SET pg_stash_advice.stash_name = 'lab_plans';
-- Or, for this session only: SET pg_stash_advice.stash_name = 'lab_plans';
Use the real query identifier from EXPLAIN (VERBOSE, ...). New sessions that see that GUC will consult the named stash. Changing a stash entry or stash_name does not rewrite plans that are already cached. Official docs also warn that the security model is limited: creating or editing stashes is restricted, but any user may set pg_stash_advice.stash_name for their session and may be able to see advice stored under that name.
HiDataLinker will not create the stash for you, will not apply stashed advice itself, and does not ship a stash manager. After the extension exists, it may show up in the object tree; that is inventory, not a plan-stability console. Mayur applies a stash with ALTER DATABASE / ALTER ROLE so application SQL can stay unchanged. That is still server-side configuration.
Common mistakes (and the fix)
- Forgetting to load
pg_plan_adviceand wondering whyEXPLAIN (PLAN_ADVICE)is rejected. Load the module first, or preload it on the server. - Expecting a visual PLAN_ADVICE or IO toggle. Visual EXPLAIN is ANALYZE / BUFFERS only; run the official options in the SQL editor.
- Enforcing a full generated advice string when you only needed one tag, or forcing a plan the planner would never consider.
- Leaving stale advice in place after the data distribution has changed. Refresh statistics, re-read the plan, and drop or trim advice you no longer need.
- Assuming
pg_stash_adviceworks withoutshared_preload_libraries,CREATE EXTENSION, andcompute_query_id, or that HiDataLinker will edit those settings. - Expecting already-cached plans to pick up new session advice or a new stash entry. Plan again, or
DISCARD PLANS. - Treating the client as a fix for autovacuum debt. Plan advice does not replace timely
ANALYZE.
HiDataLinker is a thin Tauri desktop app for PostgreSQL and MySQL — paste DATABASE_URL, keep creds local, and avoid seat / connection / tab freemium walls. Honest v1: MySQL + PostgreSQL as marketed; not a plan-advice console, not a stash manager, and not a property-graph client.
Soft next step
Need a desktop GUI that can run PostgreSQL 19 EXPLAIN (PLAN_ADVICE) and SET pg_plan_advice.advice in a SQL editor, and compare plans with visual EXPLAIN ANALYZE / BUFFERS, without a freemium wall and without a plan-advice UI the product does not have?