The example stores a query definition and executes it with different variables.
It then changes the query ordering and updates the people that the query selects.
The plan operation below reads and controls the accepted plan for a stored query or mutation.
It works without a planner plugin. Mutation selections use the query planner and report selection feedback.
Background trials of a mutation execute its selection only. They do not apply its patch.
The adaptive planner can retain separate plans for exact parameter values.
Values without a retained plan use the shared fallback plan.
Measured repeated-use savings must justify the lookup, trial and storage costs within the database memory budget.
Optional anchor probes can improve estimates when their measured cost justifies the work.
An incomplete probe supplies a lower bound and cannot prove that a query is empty.
Use explain for the current accepted state and its paged revision history.
Use status for the current state alone, or history for a history page.
Each history entry includes the plan version, source and reason for the change.
Trial reasons report the candidates and their measured outcomes.
The pin action prevents automatic replacement for every parameter value.
The unpin action permits learning again.
The replan action rebuilds the fallback plan and clears specialized parameter plans. It preserves the global pin.
The revert action restores a complete historical state, including its pin and parameter plans.
Revert requires the exact plan transaction and the same authored definition revision.
Explicit changes compare both authored and accepted plan revisions inside the commit.
A concurrent definition or plan change reports conflict.
Every returned plan document owns its buffers and remains readable after the database closes.
explain, status, history, pin, unpin, replan or revert. Pin prevents every automatic replacement. Replan chooses a statistics plan and preserves a pin. Unpin permits learning. Revert restores an exact earlier plan transaction only if its authored revision still matches; it preserves that revision's pin.
For history or explain, the exclusive lower transaction bound, or zero to start. For revert, the exact historical plan transaction. Other actions require zero.
For history or explain, the positive diagnostic buffer capacity in bytes. The database may grant less. Exhaustion reports out_of_memory with no partial response. Other actions require zero. Returned documents own independent buffers after the call.
output
stardust_result **
Owned output
Required
Receives a library-owned handle. Release it after use.