From c23bc6fbb02455ee9c2e0206747a929aa79b7d01 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 9 May 2001 23:13:37 +0000 Subject: First cut at making indexscan cost estimates depend on correlation between index order and table order. --- doc/src/sgml/indexcost.sgml | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/indexcost.sgml b/doc/src/sgml/indexcost.sgml index 9c781f97fc8..482a2e199e6 100644 --- a/doc/src/sgml/indexcost.sgml +++ b/doc/src/sgml/indexcost.sgml @@ -1,5 +1,5 @@ @@ -57,7 +57,8 @@ amcostestimate (Query *root, List *indexQuals, Cost *indexStartupCost, Cost *indexTotalCost, - Selectivity *indexSelectivity); + Selectivity *indexSelectivity, + double *indexCorrelation); The first four parameters are inputs: @@ -103,7 +104,7 @@ amcostestimate (Query *root, - The last three parameters are pass-by-reference outputs: + The last four parameters are pass-by-reference outputs: @@ -132,6 +133,16 @@ amcostestimate (Query *root, + + + *indexCorrelation + + + Set to correlation coefficient between index scan order and + underlying table's order + + + @@ -172,6 +183,13 @@ amcostestimate (Query *root, tuples that actually pass the given qual conditions. + + 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. + + Cost Estimation @@ -224,6 +242,14 @@ amcostestimate (Query *root, + + + + 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). + + @@ -237,8 +263,8 @@ amcostestimate (Query *root, prorettype = 0 -pronargs = 7 -proargtypes = 0 0 0 0 0 0 0 +pronargs = 8 +proargtypes = 0 0 0 0 0 0 0 0 We use zero ("opaque") for all the arguments since none of them have types -- cgit v1.2.3