Skip to content

Commit 6fe0eb9

Browse files
committed
Add Cardinality typedef
Similar to Cost and Selectivity, this is just a double, which can be used in path and plan nodes to give some hint about the meaning of a field. Discussion: https://www.postgresql.org/message-id/c091e5cd-45f8-69ee-6a9b-de86912cc7e7@enterprisedb.com
1 parent 1316be2 commit 6fe0eb9

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

src/include/nodes/nodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ extern bool equal(const void *a, const void *b);
668668
*/
669669
typedef double Selectivity; /* fraction of tuples a qualifier will pass */
670670
typedef double Cost; /* execution cost (in page-access units) */
671+
typedef double Cardinality; /* (estimated) number of rows or other integer count */
671672

672673

673674
/*

src/include/nodes/parsenodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ typedef struct RangeTblEntry
11441144
* Fields valid for ENR RTEs (else NULL/zero):
11451145
*/
11461146
char *enrname; /* name of ephemeral named relation */
1147-
double enrtuples; /* estimated or actual from caller */
1147+
Cardinality enrtuples; /* estimated or actual from caller */
11481148

11491149
/*
11501150
* Fields valid in all RTEs:

src/include/nodes/pathnodes.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ struct PlannerInfo
334334

335335
MemoryContext planner_cxt; /* context holding PlannerInfo */
336336

337-
double total_table_pages; /* # of pages in all non-dummy tables of
337+
Cardinality total_table_pages; /* # of pages in all non-dummy tables of
338338
* query */
339339

340-
double tuple_fraction; /* tuple_fraction passed to query_planner */
341-
double limit_tuples; /* limit_tuples passed to query_planner */
340+
Selectivity tuple_fraction; /* tuple_fraction passed to query_planner */
341+
Cardinality limit_tuples; /* limit_tuples passed to query_planner */
342342

343343
Index qual_security_level; /* minimum security_level for quals */
344344
/* Note: qual_security_level is zero if there are no securityQuals */
@@ -681,7 +681,7 @@ typedef struct RelOptInfo
681681
Relids relids; /* set of base relids (rangetable indexes) */
682682

683683
/* size estimates generated by planner */
684-
double rows; /* estimated number of result tuples */
684+
Cardinality rows; /* estimated number of result tuples */
685685

686686
/* per-relation planner control flags */
687687
bool consider_startup; /* keep cheap-startup-cost paths? */
@@ -718,7 +718,7 @@ typedef struct RelOptInfo
718718
List *indexlist; /* list of IndexOptInfo */
719719
List *statlist; /* list of StatisticExtInfo */
720720
BlockNumber pages; /* size estimates derived from pg_class */
721-
double tuples;
721+
Cardinality tuples;
722722
double allvisfrac;
723723
Bitmapset *eclass_indexes; /* Indexes in PlannerInfo's eq_classes list of
724724
* ECs that mention this rel */
@@ -841,7 +841,7 @@ struct IndexOptInfo
841841

842842
/* index-size statistics (from pg_class and elsewhere) */
843843
BlockNumber pages; /* number of disk pages in index */
844-
double tuples; /* number of index tuples in index */
844+
Cardinality tuples; /* number of index tuples in index */
845845
int tree_height; /* index tree height, or -1 if unknown */
846846

847847
/* index descriptor information */
@@ -1139,7 +1139,7 @@ typedef struct ParamPathInfo
11391139
NodeTag type;
11401140

11411141
Relids ppi_req_outer; /* rels supplying parameters used by path */
1142-
double ppi_rows; /* estimated number of result tuples */
1142+
Cardinality ppi_rows; /* estimated number of result tuples */
11431143
List *ppi_clauses; /* join clauses available from outer rels */
11441144
} ParamPathInfo;
11451145

@@ -1189,7 +1189,7 @@ typedef struct Path
11891189
int parallel_workers; /* desired # of workers; 0 = not parallel */
11901190

11911191
/* estimated size/costs for path (see costsize.c for more info) */
1192-
double rows; /* estimated number of result tuples */
1192+
Cardinality rows; /* estimated number of result tuples */
11931193
Cost startup_cost; /* cost expended before fetching any tuples */
11941194
Cost total_cost; /* total cost (assuming all tuples fetched) */
11951195

@@ -1452,7 +1452,7 @@ typedef struct AppendPath
14521452
List *subpaths; /* list of component Paths */
14531453
/* Index of first partial path in subpaths; list_length(subpaths) if none */
14541454
int first_partial_path;
1455-
double limit_tuples; /* hard limit on output tuples, or -1 */
1455+
Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
14561456
} AppendPath;
14571457

14581458
#define IS_DUMMY_APPEND(p) \
@@ -1474,7 +1474,7 @@ typedef struct MergeAppendPath
14741474
{
14751475
Path path;
14761476
List *subpaths; /* list of component Paths */
1477-
double limit_tuples; /* hard limit on output tuples, or -1 */
1477+
Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
14781478
} MergeAppendPath;
14791479

14801480
/*
@@ -1515,7 +1515,7 @@ typedef struct MemoizePath
15151515
List *param_exprs; /* cache keys */
15161516
bool singlerow; /* true if the cache entry is to be marked as
15171517
* complete after caching the first record. */
1518-
double calls; /* expected number of rescans */
1518+
Cardinality calls; /* expected number of rescans */
15191519
uint32 est_entries; /* The maximum number of entries that the
15201520
* planner expects will fit in the cache, or 0
15211521
* if unknown */
@@ -1667,7 +1667,7 @@ typedef struct HashPath
16671667
JoinPath jpath;
16681668
List *path_hashclauses; /* join clauses used for hashing */
16691669
int num_batches; /* number of batches expected */
1670-
double inner_rows_total; /* total inner rows expected */
1670+
Cardinality inner_rows_total; /* total inner rows expected */
16711671
} HashPath;
16721672

16731673
/*
@@ -1770,7 +1770,7 @@ typedef struct AggPath
17701770
Path *subpath; /* path representing input source */
17711771
AggStrategy aggstrategy; /* basic strategy, see nodes.h */
17721772
AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
1773-
double numGroups; /* estimated number of groups in input */
1773+
Cardinality numGroups; /* estimated number of groups in input */
17741774
uint64 transitionSpace; /* for pass-by-ref transition data */
17751775
List *groupClause; /* a list of SortGroupClause's */
17761776
List *qual; /* quals (HAVING quals), if any */
@@ -1784,7 +1784,7 @@ typedef struct GroupingSetData
17841784
{
17851785
NodeTag type;
17861786
List *set; /* grouping set as list of sortgrouprefs */
1787-
double numGroups; /* est. number of result groups */
1787+
Cardinality numGroups; /* est. number of result groups */
17881788
} GroupingSetData;
17891789

17901790
typedef struct RollupData
@@ -1793,7 +1793,7 @@ typedef struct RollupData
17931793
List *groupClause; /* applicable subset of parse->groupClause */
17941794
List *gsets; /* lists of integer indexes into groupClause */
17951795
List *gsets_data; /* list of GroupingSetData */
1796-
double numGroups; /* est. number of result groups */
1796+
Cardinality numGroups; /* est. number of result groups */
17971797
bool hashable; /* can be hashed */
17981798
bool is_hashed; /* to be implemented as a hashagg */
17991799
} RollupData;
@@ -1844,7 +1844,7 @@ typedef struct SetOpPath
18441844
List *distinctList; /* SortGroupClauses identifying target cols */
18451845
AttrNumber flagColIdx; /* where is the flag column, if any */
18461846
int firstFlag; /* flag value for first input relation */
1847-
double numGroups; /* estimated number of groups in input */
1847+
Cardinality numGroups; /* estimated number of groups in input */
18481848
} SetOpPath;
18491849

18501850
/*
@@ -1857,7 +1857,7 @@ typedef struct RecursiveUnionPath
18571857
Path *rightpath;
18581858
List *distinctList; /* SortGroupClauses identifying target cols */
18591859
int wtParam; /* ID of Param representing work table */
1860-
double numGroups; /* estimated number of groups in input */
1860+
Cardinality numGroups; /* estimated number of groups in input */
18611861
} RecursiveUnionPath;
18621862

18631863
/*
@@ -2612,7 +2612,7 @@ typedef struct
26122612
typedef struct
26132613
{
26142614
bool limit_needed;
2615-
double limit_tuples;
2615+
Cardinality limit_tuples;
26162616
int64 count_est;
26172617
int64 offset_est;
26182618
} FinalPathExtraData;
@@ -2643,15 +2643,15 @@ typedef struct JoinCostWorkspace
26432643
Cost inner_rescan_run_cost;
26442644

26452645
/* private for cost_mergejoin code */
2646-
double outer_rows;
2647-
double inner_rows;
2648-
double outer_skip_rows;
2649-
double inner_skip_rows;
2646+
Cardinality outer_rows;
2647+
Cardinality inner_rows;
2648+
Cardinality outer_skip_rows;
2649+
Cardinality inner_skip_rows;
26502650

26512651
/* private for cost_hashjoin code */
26522652
int numbuckets;
26532653
int numbatches;
2654-
double inner_rows_total;
2654+
Cardinality inner_rows_total;
26552655
} JoinCostWorkspace;
26562656

26572657
/*

src/include/nodes/plannodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef struct Plan
120120
/*
121121
* planner's estimate of result size of this plan step
122122
*/
123-
double plan_rows; /* number of rows plan is expected to emit */
123+
Cardinality plan_rows; /* number of rows plan is expected to emit */
124124
int plan_width; /* average row width in bytes */
125125

126126
/*
@@ -976,7 +976,7 @@ typedef struct Hash
976976
AttrNumber skewColumn; /* outer join key's column #, or zero */
977977
bool skewInherit; /* is outer join rel an inheritance tree? */
978978
/* all other info is in the parent HashJoin node */
979-
double rows_total; /* estimate total rows if parallel_aware */
979+
Cardinality rows_total; /* estimate total rows if parallel_aware */
980980
} Hash;
981981

982982
/* ----------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy