mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
First cut at making indexscan cost estimates depend on correlation
between index order and table order.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/indexcost.sgml,v 2.6 2000/12/22 21:51:57 petere Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/indexcost.sgml,v 2.7 2001/05/09 23:13:34 tgl Exp $
|
||||
-->
|
||||
|
||||
<chapter id="indexcost">
|
||||
@ -57,7 +57,8 @@ amcostestimate (Query *root,
|
||||
List *indexQuals,
|
||||
Cost *indexStartupCost,
|
||||
Cost *indexTotalCost,
|
||||
Selectivity *indexSelectivity);
|
||||
Selectivity *indexSelectivity,
|
||||
double *indexCorrelation);
|
||||
</programlisting>
|
||||
|
||||
The first four parameters are inputs:
|
||||
@ -103,7 +104,7 @@ amcostestimate (Query *root,
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The last three parameters are pass-by-reference outputs:
|
||||
The last four parameters are pass-by-reference outputs:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
@ -132,6 +133,16 @@ amcostestimate (Query *root,
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>*indexCorrelation</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Set to correlation coefficient between index scan order and
|
||||
underlying table's order
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
@ -172,6 +183,13 @@ amcostestimate (Query *root,
|
||||
tuples that actually pass the given qual conditions.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The indexCorrelation should be set to the correlation (ranging between
|
||||
-1.0 and 1.0) between the index order and the table order. This is used
|
||||
to adjust the estimate for the cost of fetching tuples from the main
|
||||
table.
|
||||
</para>
|
||||
|
||||
<procedure>
|
||||
<title>Cost Estimation</title>
|
||||
<para>
|
||||
@ -224,6 +242,14 @@ amcostestimate (Query *root,
|
||||
</programlisting>
|
||||
</para>
|
||||
</step>
|
||||
|
||||
<step>
|
||||
<para>
|
||||
Estimate the index correlation. For a simple ordered index on a single
|
||||
field, this can be retrieved from pg_statistic. If the correlation
|
||||
is not known, the conservative estimate is zero (no correlation).
|
||||
</para>
|
||||
</step>
|
||||
</procedure>
|
||||
|
||||
<para>
|
||||
@ -237,8 +263,8 @@ amcostestimate (Query *root,
|
||||
|
||||
<programlisting>
|
||||
prorettype = 0
|
||||
pronargs = 7
|
||||
proargtypes = 0 0 0 0 0 0 0
|
||||
pronargs = 8
|
||||
proargtypes = 0 0 0 0 0 0 0 0
|
||||
</programlisting>
|
||||
|
||||
We use zero ("opaque") for all the arguments since none of them have types
|
||||
|
Reference in New Issue
Block a user