mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +03:00
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
This commit is contained in:
parent
57d11ef028
commit
eb5c4e953b
@ -140,6 +140,7 @@
|
|||||||
#include "utils/timestamp.h"
|
#include "utils/timestamp.h"
|
||||||
#include "utils/typcache.h"
|
#include "utils/typcache.h"
|
||||||
|
|
||||||
|
#define DEFAULT_PAGE_CPU_MULTIPLIER 50.0
|
||||||
|
|
||||||
/* Hooks for plugins to get control when we ask for stats */
|
/* Hooks for plugins to get control when we ask for stats */
|
||||||
get_relation_stats_hook_type get_relation_stats_hook = NULL;
|
get_relation_stats_hook_type get_relation_stats_hook = NULL;
|
||||||
@ -6865,7 +6866,7 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
* touched. The number of such pages is btree tree height plus one (ie,
|
* touched. The number of such pages is btree tree height plus one (ie,
|
||||||
* we charge for the leaf page too). As above, charge once per SA scan.
|
* we charge for the leaf page too). As above, charge once per SA scan.
|
||||||
*/
|
*/
|
||||||
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
|
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
|
||||||
costs.indexStartupCost += descentCost;
|
costs.indexStartupCost += descentCost;
|
||||||
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
||||||
|
|
||||||
@ -7060,7 +7061,7 @@ gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
/*
|
/*
|
||||||
* Likewise add a per-page charge, calculated the same as for btrees.
|
* Likewise add a per-page charge, calculated the same as for btrees.
|
||||||
*/
|
*/
|
||||||
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
|
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
|
||||||
costs.indexStartupCost += descentCost;
|
costs.indexStartupCost += descentCost;
|
||||||
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
||||||
|
|
||||||
@ -7115,7 +7116,7 @@ spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
/*
|
/*
|
||||||
* Likewise add a per-page charge, calculated the same as for btrees.
|
* Likewise add a per-page charge, calculated the same as for btrees.
|
||||||
*/
|
*/
|
||||||
descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
|
descentCost = (index->tree_height + 1) * DEFAULT_PAGE_CPU_MULTIPLIER * cpu_operator_cost;
|
||||||
costs.indexStartupCost += descentCost;
|
costs.indexStartupCost += descentCost;
|
||||||
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
costs.indexTotalCost += costs.num_sa_scans * descentCost;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user