-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store the total number of plans in PlannedStmt
.
#1
base: master
Are you sure you want to change the base?
Conversation
336fb9c
to
9d21e62
Compare
I am assuming that the performance implications of this are minor and plan-time only. Nonetheless if we want to submit this upstream we will definitely need to benchmark it to prove that is the case. |
src/include/nodes/plannodes.h
Outdated
@@ -97,6 +97,8 @@ typedef struct PlannedStmt | |||
/* statement location in source string (copied from Query) */ | |||
ParseLoc stmt_location; /* start location, or -1 if unknown */ | |||
ParseLoc stmt_len; /* length in bytes; 0 means "rest of string" */ | |||
|
|||
int total_plans; /* indicates the number of plan nodes in the statement */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not unsigned int ?
also, let's name it plan_nodes_count
or similar as total_plans
could indicate that there are potentially multiple plans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes a lot of sense, will address shortly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/backend/nodes/gen_node_support.pl doesn't support unsigned int
:
could not handle type "unsigned int" in struct "PlannedStmt" field "plan_nodes_count"
Extensions that use planner/executor hooks can't precisely pre-allocate memory for data structures mirroring the plan as the number of plan nodes is unknown. This information is effectively collected in the standard planner in the node ID counter but was discarded at the end. This change preserves this information.
9d21e62
to
68d38d2
Compare
For me, it may be resolved by just walking through the plan nodes: Some people want to take into account only nodes from the plan, while others want to count CTEs and Subplans nodes, too. It depends on the purpose. |
Extensions that use planner/executor hooks can't precisely pre-allocate memory for data structures mirroring the plan as the number of plan nodes is unknown.
This information is effectively collected in the standard planner in the node ID counter but was discarded at the end. This change preserves this information.