pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] PR #658: Swap max costing values to align with upstream guidance
Date: Fri, 23 Aug 2024 21:55:35 +0000
Message-ID: <gh-pgvector-pgvector-658@github.com> (raw)

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

inline patch 1: src/hnsw.c, src/ivfflat.c (+6/-4 lines) download inline-1.patchdiff --git a/src/hnsw.c b/src/hnsw.c index 0850a69e7..97e43a8a7 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -9,6 +9,7 @@ #include "commands/vacuum.h" #include "hnsw.h" #include "miscadmin.h" +#include "utils/float.h" #include "utils/guc.h" #include "utils/selfuncs.h" @@ -112,8 +113,8 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, /* Never use index without order */ if (path->indexorderbys == NULL) { - *indexStartupCost = DBL_MAX; - *indexTotalCost = DBL_MAX; + *indexStartupCost = get_float8_infinity(); + *indexTotalCost = get_float8_infinity(); *indexSelectivity = 0; *indexCorrelation = 0; *indexPages = 0; diff --git a/src/ivfflat.c b/src/ivfflat.c index 415579b7a..a1e2e1d28 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -7,6 +7,7 @@ #include "commands/progress.h" #include "commands/vacuum.h" #include "ivfflat.h" +#include "utils/float.h" #include "utils/guc.h" #include "utils/selfuncs.h" #include "utils/spccache.h" @@ -78,8 +79,8 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, /* Never use index without order */ if (path->indexorderbys == NULL) { - *indexStartupCost = DBL_MAX; - *indexTotalCost = DBL_MAX; + *indexStartupCost = get_float8_infinity(); + *indexTotalCost = get_float8_infinity(); *indexSelectivity = 0; *indexCorrelation = 0; *indexPages = 0;

view thread (6+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-658@github.com>
Permalink:  ../gh-pgvector-pgvector-658@github.com/

 ·  · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox