Update comments about clause selectivity estimation.
This commit is contained in:
parent
44763a2b23
commit
30da344cb1
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.51 1999/07/24 23:21:08 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.52 1999/07/30 22:34:17 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -59,6 +59,9 @@ make_one_rel(Query *root, List *rels)
|
|||||||
if (levels_needed <= 0)
|
if (levels_needed <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate access paths for the base rels.
|
||||||
|
*/
|
||||||
set_base_rel_pathlist(root, rels);
|
set_base_rel_pathlist(root, rels);
|
||||||
|
|
||||||
if (levels_needed <= 1)
|
if (levels_needed <= 1)
|
||||||
@ -73,8 +76,10 @@ make_one_rel(Query *root, List *rels)
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This means that joins or sorts are required. set selectivities
|
* This means that joins or sorts are required. Set selectivities
|
||||||
* of clauses that have not been set by an index.
|
* of any clauses not yet set. (I think that this is redundant;
|
||||||
|
* set_base_rel_pathlist should have set them all already. But
|
||||||
|
* a scan to check that they are all set doesn't cost much...)
|
||||||
*/
|
*/
|
||||||
set_rest_relselec(root, rels);
|
set_rest_relselec(root, rels);
|
||||||
|
|
||||||
@ -131,11 +136,15 @@ set_base_rel_pathlist(Query *root, List *rels)
|
|||||||
|
|
||||||
set_cheapest(rel, rel->pathlist);
|
set_cheapest(rel, rel->pathlist);
|
||||||
|
|
||||||
/*
|
/* Set the selectivity estimates for any restriction clauses that
|
||||||
* if there is a qualification of sequential scan the selec. value
|
* didn't get set as a byproduct of index-path selectivity estimation
|
||||||
* is not set -- so set it explicitly -- Sunita
|
* (see create_index_path()).
|
||||||
*/
|
*/
|
||||||
set_rest_selec(root, rel->restrictinfo);
|
set_rest_selec(root, rel->restrictinfo);
|
||||||
|
|
||||||
|
/* Calculate the estimated size (post-restrictions) and tuple width
|
||||||
|
* for this base rel. This uses the restriction clause selectivities.
|
||||||
|
*/
|
||||||
rel->size = compute_rel_size(rel);
|
rel->size = compute_rel_size(rel);
|
||||||
rel->width = compute_rel_width(rel);
|
rel->width = compute_rel_width(rel);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.51 1999/07/30 04:07:25 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.52 1999/07/30 22:34:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -412,14 +412,18 @@ create_index_path(Query *root,
|
|||||||
/*
|
/*
|
||||||
* Set selectivities of clauses used with index to the selectivity
|
* Set selectivities of clauses used with index to the selectivity
|
||||||
* of this index, subdividing the selectivity equally over each of
|
* of this index, subdividing the selectivity equally over each of
|
||||||
* the clauses.
|
* the clauses. To the extent that index_selectivity() can make a
|
||||||
|
* better estimate of the joint selectivity of these clauses than
|
||||||
|
* the product of individual estimates from compute_clause_selec()
|
||||||
|
* would be, this should give us a more accurate estimate of the
|
||||||
|
* total selectivity of all the clauses.
|
||||||
*
|
*
|
||||||
* XXX Can this divide the selectivities in a better way?
|
* XXX If there is more than one useful index for this rel, and the
|
||||||
*
|
* indexes can be used with different but overlapping groups of
|
||||||
* XXX In fact, why the heck are we doing this at all? We already
|
* restriction clauses, we may end up with too optimistic an estimate,
|
||||||
* set the cost for the indexpath, and it's far from obvious that
|
* since set_clause_selectivities() will save the minimum of the
|
||||||
* the selectivity of the path should have any effect on estimates
|
* per-clause selectivity estimated with each index. But that should
|
||||||
* made for other contexts...
|
* be fairly unlikely for typical index usage.
|
||||||
*/
|
*/
|
||||||
clausesel = pow(selec, 1.0 / (double) length(restriction_clauses));
|
clausesel = pow(selec, 1.0 / (double) length(restriction_clauses));
|
||||||
set_clause_selectivities(restriction_clauses, clausesel);
|
set_clause_selectivities(restriction_clauses, clausesel);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user