mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 00:26:55 +08:00
Improved code [skip ci]
This commit is contained in:
12
src/hnsw.c
12
src/hnsw.c
@@ -113,10 +113,6 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
{
|
{
|
||||||
GenericCosts costs;
|
GenericCosts costs;
|
||||||
int m;
|
int m;
|
||||||
int entryLevel;
|
|
||||||
int layer0TuplesMax;
|
|
||||||
double layer0Selectivity;
|
|
||||||
double scalingFactor = 0.55;
|
|
||||||
double ratio;
|
double ratio;
|
||||||
double startupPages;
|
double startupPages;
|
||||||
double spc_seq_page_cost;
|
double spc_seq_page_cost;
|
||||||
@@ -170,9 +166,11 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
*/
|
*/
|
||||||
if (path->indexinfo->tuples > 0)
|
if (path->indexinfo->tuples > 0)
|
||||||
{
|
{
|
||||||
entryLevel = (int) (log(path->indexinfo->tuples) * HnswGetMl(m));
|
double scalingFactor = 0.55;
|
||||||
layer0TuplesMax = HnswGetLayerM(m, 0) * hnsw_ef_search;
|
int entryLevel = (int) (log(path->indexinfo->tuples) * HnswGetMl(m));
|
||||||
layer0Selectivity = scalingFactor * log(path->indexinfo->tuples) / (log(m) * (1 + log(hnsw_ef_search)));
|
int layer0TuplesMax = HnswGetLayerM(m, 0) * hnsw_ef_search;
|
||||||
|
double layer0Selectivity = scalingFactor * log(path->indexinfo->tuples) / (log(m) * (1 + log(hnsw_ef_search)));
|
||||||
|
|
||||||
ratio = (entryLevel * m + layer0TuplesMax * layer0Selectivity) / path->indexinfo->tuples;
|
ratio = (entryLevel * m + layer0TuplesMax * layer0Selectivity) / path->indexinfo->tuples;
|
||||||
|
|
||||||
if (ratio > 1)
|
if (ratio > 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user