mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Drop cheap-startup-cost paths during add_path() if we don't need them.
We can detect whether the planner top level is going to care at all about cheap startup cost (it will only do so if query_planner's tuple_fraction argument is greater than zero). If it isn't, we might as well discard paths immediately whose only advantage over others is cheap startup cost. This turns out to get rid of quite a lot of paths in complex queries --- I saw planner runtime reduction of more than a third on one large query. Since add_path isn't currently passed the PlannerInfo "root", the easiest way to tell it whether to do this was to add a bool flag to RelOptInfo. That's a bit redundant, since all relations in a given query level will have the same setting. But in the future it's possible that we'd refine the control decision to work on a per-relation basis, so this seems like a good arrangement anyway. Per my suggestion of a few months ago.
This commit is contained in:
@@ -299,6 +299,8 @@ typedef struct PlannerInfo
|
||||
* clauses have been applied (ie, output rows of a plan for it)
|
||||
* width - avg. number of bytes per tuple in the relation after the
|
||||
* appropriate projections have been done (ie, output width)
|
||||
* consider_startup - true if there is any value in keeping paths for
|
||||
* this rel on the basis of having cheap startup cost
|
||||
* reltargetlist - List of Var and PlaceHolderVar nodes for the values
|
||||
* we need to output from this relation.
|
||||
* List is in no particular order, but all rels of an
|
||||
@@ -405,6 +407,9 @@ typedef struct RelOptInfo
|
||||
double rows; /* estimated number of result tuples */
|
||||
int width; /* estimated avg width of result tuples */
|
||||
|
||||
/* per-relation planner control flags */
|
||||
bool consider_startup; /* keep cheap-startup-cost paths? */
|
||||
|
||||
/* materialization information */
|
||||
List *reltargetlist; /* Vars to be output by scan of relation */
|
||||
List *pathlist; /* Path structures */
|
||||
|
Reference in New Issue
Block a user