aboutsummaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-07-24 15:41:18 +0900
committerMichael Paquier <michael@paquier.xyz>2025-07-24 15:41:18 +0900
commit719dcf3c42260ceebfa2e8f6171a61161737a265 (patch)
treeb31988d6fb882731c6dfa323ebdc2abe58fb6880 /src/include/nodes
parentdf335618ed87eecdef44a95e453e345a55a14ad8 (diff)
downloadpostgresql-719dcf3c42260ceebfa2e8f6171a61161737a265.tar.gz
postgresql-719dcf3c42260ceebfa2e8f6171a61161737a265.zip
Introduce field tracking cached plan type in PlannedStmt
PlannedStmt gains a new field, called CachedPlanType, able to track if a given plan tree originates from the cache and if we are dealing with a generic or custom cached plan. This field can be used for monitoring or statistical purposes, in the executor hooks, for example, based on the planned statement attached to a QueryDesc. A patch is under discussion for pg_stat_statements to provide an equivalent of the counters in pg_prepared_statements for custom and generic plans, to provide a more global view of such data, as this data is now restricted to the current session. The concept introduced in this commit is useful on its own, and has been extracted from a larger patch by the same author. Author: Sami Imseih <samimseih@gmail.com> Reviewed-by: Andrei Lepikhov <lepihov@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAA5RZ0uFw8Y9GCFvafhC=OA8NnMqVZyzXPfv_EePOt+iv1T-qQ@mail.gmail.com
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/plannodes.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 4f59e30d62d..46e2e09ea35 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -29,6 +29,20 @@
*/
/* ----------------
+ * CachedPlanType
+ *
+ * CachedPlanType identifies whether a PlannedStmt is a cached plan, and if
+ * so, whether it is generic or custom.
+ * ----------------
+ */
+typedef enum CachedPlanType
+{
+ PLAN_CACHE_NONE = 0, /* Not a cached plan */
+ PLAN_CACHE_GENERIC, /* Generic cached plan */
+ PLAN_CACHE_CUSTOM, /* Custom cached plan */
+} CachedPlanType;
+
+/* ----------------
* PlannedStmt node
*
* The output of the planner is a Plan tree headed by a PlannedStmt node.
@@ -58,6 +72,9 @@ typedef struct PlannedStmt
/* plan identifier (can be set by plugins) */
int64 planId;
+ /* type of cached plan */
+ CachedPlanType cached_plan_type;
+
/* is it insert|update|delete|merge RETURNING? */
bool hasReturning;