Skip to content

Commit

Permalink
[##22388] YSQL: Change name of bitmap_exceeded_work_mem_cost
Browse files Browse the repository at this point in the history
Summary:
Because `bitmap_exceeded_work_mem_cost` doesn't contain the phrase `disable_cost`, it's easy to
miss when someone try to find all the places that inflates the cost values, e.g.
investigate into cost overflow, precision losses with complex plans, etc.

Change the name to `bitmap_exceeded_work_mem_disable_cost`.
Jira: DB-11285

Test Plan: Jenkins: compile only, build type: debug

Reviewers: tnayak, amartsinchyk, mtakahara

Reviewed By: mtakahara

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D35045
  • Loading branch information
timothy-e committed May 14, 2024
1 parent c6291aa commit 49a8e47
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/postgres/src/backend/optimizer/path/costsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ double yb_local_throughput_cost = YB_DEFAULT_LOCAL_THROUGHPUT_COST;
int effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;

Cost disable_cost = 1.0e10;
Cost bitmap_exceeded_work_mem_cost = 5.0e9;
Cost bitmap_exceeded_work_mem_disable_cost = 5.0e9;

int max_parallel_workers_per_gather = 2;

Expand Down Expand Up @@ -1265,8 +1265,8 @@ yb_cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec, int *ybctid

double bitmap_rows = clamp_row_est(ipath->indexselectivity * ipath->path.parent->tuples);

if (bitmap_rows > maxentries && *cost < bitmap_exceeded_work_mem_cost)
*cost += bitmap_exceeded_work_mem_cost;
if (bitmap_rows > maxentries && *cost < bitmap_exceeded_work_mem_disable_cost)
*cost += bitmap_exceeded_work_mem_disable_cost;

/* Update the node cost with new calculations */
ipath->indextotalcost = *cost;
Expand Down Expand Up @@ -1359,11 +1359,11 @@ yb_cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root)

selec *= subselec;

if (subcost < bitmap_exceeded_work_mem_cost)
if (subcost < bitmap_exceeded_work_mem_disable_cost)
startup_cost += subcost;
else
{
startup_cost += subcost - bitmap_exceeded_work_mem_cost;
startup_cost += subcost - bitmap_exceeded_work_mem_disable_cost;
exceeded_work_mem = true;
}

Expand All @@ -1376,7 +1376,7 @@ yb_cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root)
}

if (exceeded_work_mem)
startup_cost += bitmap_exceeded_work_mem_cost;
startup_cost += bitmap_exceeded_work_mem_disable_cost;

path->bitmapselectivity = selec;
path->path.rows = least_rows * selec;
Expand Down Expand Up @@ -1439,11 +1439,11 @@ yb_cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root)

selec += subselec;

if (subcost < bitmap_exceeded_work_mem_cost)
if (subcost < bitmap_exceeded_work_mem_disable_cost)
startup_cost += subcost;
else
{
startup_cost += subcost - bitmap_exceeded_work_mem_cost;
startup_cost += subcost - bitmap_exceeded_work_mem_disable_cost;
exceeded_work_mem = true;
}

Expand All @@ -1464,7 +1464,7 @@ yb_cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root)
if (exceeded_work_mem ||
path->path.rows > yb_tbm_calculate_entries(work_mem * 1024L,
path->ybctid_width))
startup_cost += bitmap_exceeded_work_mem_cost;
startup_cost += bitmap_exceeded_work_mem_disable_cost;

path->bitmapselectivity = Min(selec, 1.0);
path->path.rows = Min(path->path.parent->rows, total_rows) *
Expand Down Expand Up @@ -7472,7 +7472,7 @@ yb_cost_bitmap_table_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
startup_cost += indexTotalCost;

/* we fall back to a sequential scan if we exceed work_mem */
if (indexTotalCost > bitmap_exceeded_work_mem_cost)
if (indexTotalCost > bitmap_exceeded_work_mem_disable_cost)
{
yb_cost_seqscan(path, root, baserel, param_info);
if (path->startup_cost > disable_cost)
Expand Down

0 comments on commit 49a8e47

Please sign in to comment.