Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30da344

Browse files
committed
Update comments about clause selectivity estimation.
1 parent44763a2 commit30da344

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

‎src/backend/optimizer/path/allpaths.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.51 1999/07/24 23:21:08 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.52 1999/07/30 22:34:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -59,6 +59,9 @@ make_one_rel(Query *root, List *rels)
5959
if (levels_needed <=0)
6060
returnNULL;
6161

62+
/*
63+
* Generate access paths for the base rels.
64+
*/
6265
set_base_rel_pathlist(root,rels);
6366

6467
if (levels_needed <=1)
@@ -73,8 +76,10 @@ make_one_rel(Query *root, List *rels)
7376
{
7477

7578
/*
76-
* This means that joins or sorts are required. set selectivities
77-
* of clauses that have not been set by an index.
79+
* This means that joins or sorts are required. Set selectivities
80+
* of any clauses not yet set. (I think that this is redundant;
81+
* set_base_rel_pathlist should have set them all already. But
82+
* a scan to check that they are all set doesn't cost much...)
7883
*/
7984
set_rest_relselec(root,rels);
8085

@@ -131,11 +136,15 @@ set_base_rel_pathlist(Query *root, List *rels)
131136

132137
set_cheapest(rel,rel->pathlist);
133138

134-
/*
135-
*if there is a qualification ofsequential scan the selec. value
136-
*is not set -- so set it explicitly -- Sunita
139+
/* Set the selectivity estimates for any restriction clauses that
140+
*didn't get set as a byproduct ofindex-path selectivity estimation
141+
*(see create_index_path()).
137142
*/
138143
set_rest_selec(root,rel->restrictinfo);
144+
145+
/* Calculate the estimated size (post-restrictions) and tuple width
146+
* for this base rel. This uses the restriction clause selectivities.
147+
*/
139148
rel->size=compute_rel_size(rel);
140149
rel->width=compute_rel_width(rel);
141150
}

‎src/backend/optimizer/util/pathnode.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.51 1999/07/3004:07:25 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.52 1999/07/3022:34:19 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -412,14 +412,18 @@ create_index_path(Query *root,
412412
/*
413413
* Set selectivities of clauses used with index to the selectivity
414414
* of this index, subdividing the selectivity equally over each of
415-
* the clauses.
415+
* the clauses. To the extent that index_selectivity() can make a
416+
* better estimate of the joint selectivity of these clauses than
417+
* the product of individual estimates from compute_clause_selec()
418+
* would be, this should give us a more accurate estimate of the
419+
* total selectivity of all the clauses.
416420
*
417-
* XXXCan this divide the selectivities in a better way?
418-
*
419-
*XXX In fact, why the heck arewedoing this at all? We already
420-
*set the cost for theindexpath, and it's far from obvious that
421-
*the selectivityof the path should have any effect on estimates
422-
*madeforother contexts...
421+
* XXXIf there is more than one useful index for this rel, and the
422+
* indexes can be used with different but overlapping groups of
423+
*restriction clauses,wemay end up with too optimistic an estimate,
424+
*since set_clause_selectivities() will save theminimum of the
425+
*per-clause selectivityestimated with each index. But that should
426+
*be fairly unlikelyfortypical index usage.
423427
*/
424428
clausesel=pow(selec,1.0 / (double)length(restriction_clauses));
425429
set_clause_selectivities(restriction_clauses,clausesel);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp