mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 06:40:57 +08:00
Use variable for sequential ratio [skip ci]
This commit is contained in:
@@ -69,6 +69,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
GenericCosts costs;
|
GenericCosts costs;
|
||||||
int lists;
|
int lists;
|
||||||
double ratio;
|
double ratio;
|
||||||
|
double sequentialRatio = 0.5;
|
||||||
double startupPages;
|
double startupPages;
|
||||||
double spc_seq_page_cost;
|
double spc_seq_page_cost;
|
||||||
Relation index;
|
Relation index;
|
||||||
@@ -100,7 +101,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
get_tablespace_page_costs(path->indexinfo->reltablespace, NULL, &spc_seq_page_cost);
|
get_tablespace_page_costs(path->indexinfo->reltablespace, NULL, &spc_seq_page_cost);
|
||||||
|
|
||||||
/* Change some page cost from random to sequential */
|
/* Change some page cost from random to sequential */
|
||||||
costs.indexTotalCost -= 0.5 * costs.numIndexPages * (costs.spc_random_page_cost - spc_seq_page_cost);
|
costs.indexTotalCost -= sequentialRatio * costs.numIndexPages * (costs.spc_random_page_cost - spc_seq_page_cost);
|
||||||
|
|
||||||
/* Startup cost is cost before returning the first row */
|
/* Startup cost is cost before returning the first row */
|
||||||
costs.indexStartupCost = costs.indexTotalCost * ratio;
|
costs.indexStartupCost = costs.indexTotalCost * ratio;
|
||||||
@@ -110,7 +111,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
if (startupPages > path->indexinfo->rel->pages && ratio < 0.5)
|
if (startupPages > path->indexinfo->rel->pages && ratio < 0.5)
|
||||||
{
|
{
|
||||||
/* Change rest of page cost from random to sequential */
|
/* Change rest of page cost from random to sequential */
|
||||||
costs.indexStartupCost -= 0.5 * startupPages * (costs.spc_random_page_cost - spc_seq_page_cost);
|
costs.indexStartupCost -= (1 - sequentialRatio) * startupPages * (costs.spc_random_page_cost - spc_seq_page_cost);
|
||||||
|
|
||||||
/* Remove cost of extra pages */
|
/* Remove cost of extra pages */
|
||||||
costs.indexStartupCost -= (startupPages - path->indexinfo->rel->pages) * spc_seq_page_cost;
|
costs.indexStartupCost -= (startupPages - path->indexinfo->rel->pages) * spc_seq_page_cost;
|
||||||
|
|||||||
Reference in New Issue
Block a user