diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-10-04 15:48:17 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-10-04 15:48:17 -0400 |
commit | d73f4c74dd34b19c19839f7ae09fb96442728509 (patch) | |
tree | c90ec26d55c24bfca08d92cb6b43873cb64ae848 /src/include/nodes/execnodes.h | |
parent | 9ddef36278a9f676c07d0b4d9f33fa22e48ce3b5 (diff) |
In the executor, use an array of pointers to access the rangetable.
Instead of doing a lot of list_nth() accesses to es_range_table,
create a flattened pointer array during executor startup and index
into that to get at individual RangeTblEntrys.
This eliminates one source of O(N^2) behavior with lots of partitions.
(I'm not exactly convinced that it's the most important source, but
it's an easy one to fix.)
Amit Langote and David Rowley
Discussion: https://postgr.es/m/468c85d9-540e-66a2-1dde-fec2b741e688@lab.ntt.co.jp
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 35646231a4c..657b5936631 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -36,6 +36,7 @@ struct PlanState; /* forward references in this file */ struct ParallelHashJoinState; struct ExprState; struct ExprContext; +struct RangeTblEntry; /* avoid including parsenodes.h here */ struct ExprEvalStep; /* avoid including execExpr.h everywhere */ @@ -486,7 +487,9 @@ typedef struct EState Snapshot es_snapshot; /* time qual to use */ Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */ List *es_range_table; /* List of RangeTblEntry */ - Relation *es_relations; /* Array of per-es_range_table-entry Relation + struct RangeTblEntry **es_range_table_array; /* equivalent array */ + Index es_range_table_size; /* size of the range table arrays */ + Relation *es_relations; /* Array of per-range-table-entry Relation * pointers, or NULL if not yet opened */ PlannedStmt *es_plannedstmt; /* link to top of plan tree */ const char *es_sourceText; /* Source text from QueryDesc */ @@ -563,7 +566,7 @@ typedef struct EState * return, or NULL if nothing to return; es_epqTupleSet[] is true if a * particular array entry is valid; and es_epqScanDone[] is state to * remember if the tuple has been returned already. Arrays are of size - * list_length(es_range_table) and are indexed by scan node scanrelid - 1. + * es_range_table_size and are indexed by scan node scanrelid - 1. */ HeapTuple *es_epqTuple; /* array of EPQ substitute tuples */ bool *es_epqTupleSet; /* true if EPQ tuple is provided */ |