Skip to content

Commit eb5c4e9

Browse files
committed
Extract the multiplier for CPU process cost of index page into a macro
B-tree, GiST and SP-GiST all charge 50.0 * cpu_operator_cost for processing an index page. Extract this to a macro to avoid repeated magic numbers. Discussion: https://mail.google.com/mail/u/0/?ik=a20b091faa&view=om&permmsgid=msg-f%3A1751459697261369543 Author: Ronan Dunklau
1 parent 57d11ef commit eb5c4e9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
#include "utils/timestamp.h"
141141
#include "utils/typcache.h"
142142

143+
#define DEFAULT_PAGE_CPU_MULTIPLIER 50.0
143144

144145
/* Hooks for plugins to get control when we ask for stats */
145146
get_relation_stats_hook_type get_relation_stats_hook = NULL;
@@ -6865,7 +6866,7 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
68656866
* touched. The number of such pages is btree tree height plus one (ie,
68666867
* we charge for the leaf page too). As above, charge once per SA scan.
68676868
*/
6868-
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
6869+
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
68696870
costs.indexStartupCost += descentCost;
68706871
costs.indexTotalCost += costs.num_sa_scans * descentCost;
68716872

@@ -7060,7 +7061,7 @@ gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
70607061
/*
70617062
* Likewise add a per-page charge, calculated the same as for btrees.
70627063
*/
7063-
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
7064+
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
70647065
costs.indexStartupCost += descentCost;
70657066
costs.indexTotalCost += costs.num_sa_scans * descentCost;
70667067

@@ -7115,7 +7116,7 @@ spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
71157116
/*
71167117
* Likewise add a per-page charge, calculated the same as for btrees.
71177118
*/
7118-
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
7119+
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
71197120
costs.indexStartupCost += descentCost;
71207121
costs.indexTotalCost += costs.num_sa_scans * descentCost;
71217122

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