Skip to content

Commit 05fb382

Browse files
authored
Swap max costing values to align with upstream guidance (pgvector#658)
A feature targeted for PostgreSQL 18 (postgres/postgres@e2225346) that makes optimizations around disabled path nodes impacted pgvector such that PostgreSQL would choose to perform an index scan when it should have used a different scan (e.g. `SELECT count(*) FROM table`). Per upstream guidance[1], the recommendation is to switch to using `get_float8_infinity()`, which achieves the same behavior in backbranches, and can be adapated to work with the new behavior introduced in PostgreSQL 18. [1] https://www.postgresql.org/message-id/2281822.1724441531%40sss.pgh.pa.us
1 parent 8e1853f commit 05fb382

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/hnsw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "commands/vacuum.h"
1010
#include "hnsw.h"
1111
#include "miscadmin.h"
12+
#include "utils/float.h"
1213
#include "utils/guc.h"
1314
#include "utils/selfuncs.h"
1415

@@ -112,8 +113,8 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
112113
/* Never use index without order */
113114
if (path->indexorderbys == NULL)
114115
{
115-
*indexStartupCost = DBL_MAX;
116-
*indexTotalCost = DBL_MAX;
116+
*indexStartupCost = get_float8_infinity();
117+
*indexTotalCost = get_float8_infinity();
117118
*indexSelectivity = 0;
118119
*indexCorrelation = 0;
119120
*indexPages = 0;

src/ivfflat.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "commands/progress.h"
88
#include "commands/vacuum.h"
99
#include "ivfflat.h"
10+
#include "utils/float.h"
1011
#include "utils/guc.h"
1112
#include "utils/selfuncs.h"
1213
#include "utils/spccache.h"
@@ -78,8 +79,8 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
7879
/* Never use index without order */
7980
if (path->indexorderbys == NULL)
8081
{
81-
*indexStartupCost = DBL_MAX;
82-
*indexTotalCost = DBL_MAX;
82+
*indexStartupCost = get_float8_infinity();
83+
*indexTotalCost = get_float8_infinity();
8384
*indexSelectivity = 0;
8485
*indexCorrelation = 0;
8586
*indexPages = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy