diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-12-24 19:03:21 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-12-24 19:03:21 -0500 |
commit | 472d3935a2793343e450ba7cda4adbc323a984c3 (patch) | |
tree | 30fc6e85cc76a7b48ff84243237ccdc1dd41a00b /doc/src | |
parent | e2c2c2e8b1df7dfdb01e7e6f6191a569ce3c3195 (diff) | |
download | postgresql-472d3935a2793343e450ba7cda4adbc323a984c3.tar.gz postgresql-472d3935a2793343e450ba7cda4adbc323a984c3.zip |
Rethink representation of index clauses' mapping to index columns.
In commit e2c2c2e8b1df7dfdb01e7e6f6191a569ce3c3195 I made use of nested
list structures to show which clauses went with which index columns, but
on reflection that's a data structure that only an old-line Lisp hacker
could love. Worse, it adds unnecessary complication to the many places
that don't much care which clauses go with which index columns. Revert
to the previous arrangement of flat lists of clauses, and instead add a
parallel integer list of column numbers. The places that care about the
pairing can chase both lists with forboth(), while the places that don't
care just examine one list the same as before.
The only real downside to this is that there are now two more lists that
need to be passed to amcostestimate functions in case they care about
column matching (which btcostestimate does, so not passing the info is not
an option). Rather than deal with 11-argument amcostestimate functions,
pass just the IndexPath and expect the functions to extract fields from it.
That gets us down to 7 arguments which is better than 11, and it seems
more future-proof against likely additions to the information we keep
about an index path.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/indexam.sgml | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index ebd32cc8d97..07c816c38f2 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -288,9 +288,7 @@ amcanreturn (Relation indexRelation); <programlisting> void amcostestimate (PlannerInfo *root, - IndexOptInfo *index, - List *indexQuals, - List *indexOrderBys, + IndexPath *path, RelOptInfo *outer_rel, Cost *indexStartupCost, Cost *indexTotalCost, @@ -929,9 +927,7 @@ amrestrpos (IndexScanDesc scan); <programlisting> void amcostestimate (PlannerInfo *root, - IndexOptInfo *index, - List *indexQuals, - List *indexOrderBys, + IndexPath *path, RelOptInfo *outer_rel, Cost *indexStartupCost, Cost *indexTotalCost, @@ -939,7 +935,7 @@ amcostestimate (PlannerInfo *root, double *indexCorrelation); </programlisting> - The first five parameters are inputs: + The first three parameters are inputs: <variablelist> <varlistentry> @@ -952,32 +948,11 @@ amcostestimate (PlannerInfo *root, </varlistentry> <varlistentry> - <term><parameter>index</></term> + <term><parameter>path</></term> <listitem> <para> - The index being considered. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><parameter>indexQuals</></term> - <listitem> - <para> - List of index qual clauses (implicitly ANDed); - a <symbol>NIL</> list indicates no qualifiers are available. - Note that the list contains expression trees with RestrictInfo nodes - at the top, not ScanKeys. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><parameter>indexOrderBys</></term> - <listitem> - <para> - List of indexable ORDER BY operators, or <symbol>NIL</> if none. - Note that the list contains expression trees, not ScanKeys. + The index access path being considered. All fields except cost and + selectivity values are valid. </para> </listitem> </varlistentry> @@ -988,7 +963,8 @@ amcostestimate (PlannerInfo *root, <para> If the index is being considered for use in a join inner indexscan, the planner's information about the outer side of the join. Otherwise - <symbol>NULL</>. When non-<symbol>NULL</>, some of the qual clauses will be join clauses + <symbol>NULL</>. When non-<symbol>NULL</>, some of the qual clauses + will be join clauses for joins with this rel rather than being simple restriction clauses. Also, the cost estimator should expect that the index scan will be repeated for each row of the outer rel. @@ -1055,7 +1031,7 @@ amcostestimate (PlannerInfo *root, row should usually be taken as <varname>cpu_index_tuple_cost</>. In addition, an appropriate multiple of <varname>cpu_operator_cost</> should be charged for any comparison operators invoked during index processing - (especially evaluation of the <literal>indexQuals</> themselves). + (especially evaluation of the indexquals themselves). </para> <para> @@ -1103,8 +1079,8 @@ amcostestimate (PlannerInfo *root, knowledge, use the standard optimizer function <function>clauselist_selectivity()</function>: <programlisting> -*indexSelectivity = clauselist_selectivity(root, indexQuals, - index->rel->relid, +*indexSelectivity = clauselist_selectivity(root, path->indexquals, + path->indexinfo->rel->relid, JOIN_INNER, NULL); </programlisting> </para> @@ -1115,7 +1091,8 @@ amcostestimate (PlannerInfo *root, Estimate the number of index rows that will be visited during the scan. For many index types this is the same as <parameter>indexSelectivity</> times the number of rows in the index, but it might be more. (Note that the - index's size in pages and rows is available from the <structname>IndexOptInfo</> struct.) + index's size in pages and rows is available from the + <literal>path->indexinfo</> struct.) </para> </step> @@ -1137,7 +1114,7 @@ amcostestimate (PlannerInfo *root, * Also, we charge for evaluation of the indexquals at each index row. * All the costs are assumed to be paid incrementally during the scan. */ -cost_qual_eval(&index_qual_cost, indexQuals, root); +cost_qual_eval(&index_qual_cost, path->indexquals, root); *indexStartupCost = index_qual_cost.startup; *indexTotalCost = seq_page_cost * numIndexPages + (cpu_index_tuple_cost + index_qual_cost.per_tuple) * numIndexTuples; |