Only adjust cost if random_page_cost is higher than seq_page_cost

This commit is contained in:
Andrew Kane
2023-06-10 01:06:05 -07:00
parent d6ab4892fe
commit 81cc04df61

View File

@@ -118,6 +118,8 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
get_tablespace_page_costs(path->indexinfo->reltablespace, NULL, &spc_seq_page_cost);
if (costs.spc_random_page_cost > spc_seq_page_cost)
{
/* Adjust cost if needed since TOAST not included in seq scan cost */
if (costs.numIndexPages > path->indexinfo->rel->pages && ratio < 0.5)
{
@@ -132,6 +134,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
/* Change some page cost from random to sequential */
startupCost -= 0.5 * costs.numIndexPages * (costs.spc_random_page_cost - spc_seq_page_cost);
}
}
/*
* If the list selectivity is lower than what is returned from the generic