Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1fc51a

Browse files
committed
Comment fixes for extended statistics
Clean up some code comments in new extended statistics code, from 7b504eb.
1 parent dc0400c commit b1fc51a

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static List *get_relation_statistics(RelOptInfo *rel, Relation relation);
7979
* min_attr lowest valid AttrNumber
8080
* max_attr highest valid AttrNumber
8181
* indexlist list of IndexOptInfos for relation's indexes
82+
* statlist list of StatisticExtInfo for relation's statistic objects
8283
* serverid if it's a foreign table, the server OID
8384
* fdwroutine if it's a foreign table, the FDW function pointers
8485
* pages number of pages

src/backend/statistics/dependencies.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,13 @@ find_strongest_dependency(StatisticExtInfo * stats, MVDependencies * dependencie
900900

901901
/*
902902
* dependencies_clauselist_selectivity
903-
* Attempt to estimate selectivity using functional dependency statistics
903+
* Return the estimated selectivity of the given clauses using
904+
* functional dependency statistics, or 1.0 if no useful functional
905+
* dependency statistic exists.
906+
*
907+
* 'estimatedclauses' is an output argument that gets a bit set corresponding
908+
* to the (zero-based) list index of clauses that are included in the
909+
* estimated selectivity.
904910
*
905911
* Given equality clauses on attributes (a,b) we find the strongest dependency
906912
* between them, i.e. either (a=>b) or (b=>a). Assuming (a=>b) is the selected
@@ -935,7 +941,6 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
935941
AttrNumber *list_attnums;
936942
int listidx;
937943

938-
939944
/* check if there's any stats that might be useful for us. */
940945
if (!has_stats_of_kind(rel->statlist, STATS_EXT_DEPENDENCIES))
941946
return 1.0;

src/backend/statistics/extended_stats.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ multi_sort_compare_dims(int start, int end,
408408

409409
/*
410410
* has_stats_of_kind
411-
* Check that the list contains statistic of a given kind
411+
* Check that the list contains statistic of a given kind
412412
*/
413413
bool
414414
has_stats_of_kind(List *stats, char requiredkind)
@@ -428,8 +428,9 @@ has_stats_of_kind(List *stats, char requiredkind)
428428

429429
/*
430430
* choose_best_statistics
431-
* Look for statistics with the specified 'requiredkind' which have keys
432-
* that match at least two attnums.
431+
* Look for and return statistics with the specified 'requiredkind' which
432+
* have keys that match at least two of the given attnums. Return NULL if
433+
* there's no match.
433434
*
434435
* The current selection criteria is very simple - we choose the statistics
435436
* referencing the most attributes with the least keys.

src/backend/utils/cache/relcache.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4508,7 +4508,6 @@ RelationGetStatExtList(Relation relation)
45084508
NULL, 1, &skey);
45094509

45104510
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
4511-
/* TODO maybe include only already built statistics? */
45124511
result = insert_ordered_oid(result, HeapTupleGetOid(htup));
45134512

45144513
systable_endscan(indscan);

src/include/nodes/relation.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,17 +693,15 @@ typedef struct ForeignKeyOptInfo
693693
* StatisticExtInfo
694694
* Information about extended statistics for planning/optimization
695695
*
696-
* This contains information about which columns are covered by the
697-
* statistics (stakeys), which options were requested while adding the
698-
* statistics (*_enabled), and which kinds of statistics were actually
699-
* built and are available for the optimizer (*_built).
696+
* Each pg_statistic_ext row is represented by one or more nodes of this
697+
* type, or even zero if ANALYZE has not computed them.
700698
*/
701699
typedef struct StatisticExtInfo
702700
{
703701
NodeTag type;
704702

705703
Oid statOid; /* OID of the statistics row */
706-
RelOptInfo *rel; /* back-link to index's table */
704+
RelOptInfo *rel; /* back-link to statistic's table */
707705
char kind; /* statistic kind of this entry */
708706
Bitmapset *keys; /* attnums of the columns covered */
709707
} StatisticExtInfo;

0 commit comments

Comments
 (0)