pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] PR #697: Add search parameters to `EXPLAIN (SETTINGS)`
3+ messages / 3 participants
[nested] [flat]

* [pgvector/pgvector] PR #697: Add search parameters to `EXPLAIN (SETTINGS)`
@ 2024-10-22 21:25  "ankane (@ankane)" <noreply+ankane@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2024-10-22 21:25 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Wanted to get feedback on this, which adds search parameters with non-default values to `EXPLAIN (SETTINGS)`.

```text
EXPLAIN (SETTINGS) SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
                                       QUERY PLAN                                        
-----------------------------------------------------------------------------------------
 Limit  (cost=8.02..12.04 rows=2 width=48)
   ->  Index Scan using items_embedding_idx on items  (cost=8.02..12.04 rows=2 width=48)
         Order By: (embedding <-> '[3,1,2]'::vector)
 Settings: hnsw.iterative_search = 'relaxed_order'
```

This seems useful for debugging, but the downside is it'll appear for all queries, not just ones that consider an approximate index.

inline patch 1: src/hnsw.c, src/ivfflat.c (+7/-7 lines) download inline-1.patchdiff --git a/src/hnsw.c b/src/hnsw.c index 5bfc6193e..188d4a4fe 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -77,21 +77,21 @@ HnswInit(void) DefineCustomIntVariable("hnsw.ef_search", "Sets the size of the dynamic candidate list for search", "Valid range is 1..1000.", &hnsw_ef_search, - HNSW_DEFAULT_EF_SEARCH, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH, PGC_USERSET, 0, NULL, NULL, NULL); + HNSW_DEFAULT_EF_SEARCH, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); DefineCustomEnumVariable("hnsw.iterative_scan", "Sets the mode for iterative scans", NULL, &hnsw_iterative_scan, - HNSW_ITERATIVE_SCAN_OFF, hnsw_iterative_scan_options, PGC_USERSET, 0, NULL, NULL, NULL); + HNSW_ITERATIVE_SCAN_OFF, hnsw_iterative_scan_options, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); /* This is approximate and does not affect the initial scan */ DefineCustomIntVariable("hnsw.max_scan_tuples", "Sets the max number of tuples to visit for iterative scans", NULL, &hnsw_max_scan_tuples, - 20000, 1, INT_MAX, PGC_USERSET, 0, NULL, NULL, NULL); + 20000, 1, INT_MAX, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); /* Same range as hash_mem_multiplier */ DefineCustomRealVariable("hnsw.scan_mem_multiplier", "Sets the multiple of work_mem to use for iterative scans", NULL, &hnsw_scan_mem_multiplier, - 1, 1, 1000, PGC_USERSET, 0, NULL, NULL, NULL); + 1, 1, 1000, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); MarkGUCPrefixReserved("hnsw"); } diff --git a/src/ivfflat.c b/src/ivfflat.c index 9e8370ffe..c32c94ab0 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -39,16 +39,16 @@ IvfflatInit(void) DefineCustomIntVariable("ivfflat.probes", "Sets the number of probes", "Valid range is 1..lists.", &ivfflat_probes, - IVFFLAT_DEFAULT_PROBES, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL); + IVFFLAT_DEFAULT_PROBES, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); DefineCustomEnumVariable("ivfflat.iterative_scan", "Sets the mode for iterative scans", NULL, &ivfflat_iterative_scan, - IVFFLAT_ITERATIVE_SCAN_OFF, ivfflat_iterative_scan_options, PGC_USERSET, 0, NULL, NULL, NULL); + IVFFLAT_ITERATIVE_SCAN_OFF, ivfflat_iterative_scan_options, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); /* If this is less than probes, probes is used */ DefineCustomIntVariable("ivfflat.max_probes", "Sets the max number of probes for iterative scans", NULL, &ivfflat_max_probes, - IVFFLAT_MAX_LISTS, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL); + IVFFLAT_MAX_LISTS, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, GUC_EXPLAIN, NULL, NULL, NULL); MarkGUCPrefixReserved("ivfflat"); }
^ permalink raw [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] PR #697: Add search parameters to `EXPLAIN (SETTINGS)`
@ 2024-10-23 07:30  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: jkatz (@jkatz) @ 2024-10-23 07:30 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Awesome. I think even for the cases it doesn't use the index, it could be helpful to know the parameter setting, as that could ultimately involve tweaking the parameter / indexing strategy.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] PR #697 (changes requested): Add search parameters to `EXPLAIN (SETTINGS)`
@ 2026-06-14 03:51  "sagitrs (@sagitrs)" <noreply+sagitrs@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: sagitrs (@sagitrs) @ 2026-06-14 03:51 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

-

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-06-14 03:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-22 21:25 [pgvector/pgvector] PR #697: Add search parameters to `EXPLAIN (SETTINGS)` "ankane (@ankane)" <noreply+ankane@github.com>
2024-10-23 07:30 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2026-06-14 03:51 ` Re: [pgvector/pgvector] PR #697 (changes requested): Add search parameters to `EXPLAIN (SETTINGS)` "sagitrs (@sagitrs)" <noreply+sagitrs@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