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/executor/executor.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/executor/executor.h')
-rw-r--r-- | src/include/executor/executor.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 83ce989e3a3..830f42dfe3c 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -514,6 +514,15 @@ extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid); extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags); +extern void ExecInitRangeTable(EState *estate, List *rangeTable); + +static inline RangeTblEntry * +exec_rt_fetch(Index rti, EState *estate) +{ + Assert(rti > 0 && rti <= estate->es_range_table_size); + return estate->es_range_table_array[rti - 1]; +} + extern Relation ExecGetRangeTableRelation(EState *estate, Index rti); extern int executor_errposition(EState *estate, int location); |