pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
12+ messages / 5 participants
[nested] [flat]
* [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-10 19:17 "cevian (@cevian)" <noreply+cevian@github.com>
0 siblings, 0 replies; 12+ messages in thread
From: cevian (@cevian) @ 2025-01-10 19:17 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
# problem
When monitoring the recall of a vector query, you sometimes want to disable all approximate indexes to get the ground_truth and monitor recall.
Yet `enable_indexscan` isn't ideal since it turns off all indexes, causing problems in complex queries that make use of multiple tables/indexes.
# solution
Introduce a new guc convention, that if `enable_approxscan` is set and marked as off, turns off approximate indexes (by setting the cost really high as other enable_* gucs do). This guc wouldn't be defined in pgvector, but pgvector would check if it's set (just by name) and act accordingly.
I propose `enable_approxscan` as the name but open to other suggestions.
I think this convention would ideally, in time apply to all approximate Postgres indexes, certainly we'd also implement it in pgvectorscale's diskann.
# question
Curious about thoughts on whether or not this is a good idea.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-10 19:32 "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: VoVAllen (@VoVAllen) @ 2025-01-10 19:32 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
You can easily skip using index by `ORDER by distance + 0`, or manually set it's as unavailable through pg index status.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-11 02:42 "jkatz (@jkatz)" <noreply+jkatz@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: jkatz (@jkatz) @ 2025-01-11 02:42 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> manually set it's as unavailable through pg index status.
I would strongly advise against this method of disabling index scans as this may have unintended consequences around index maintenance.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-11 02:46 "jkatz (@jkatz)" <noreply+jkatz@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: jkatz (@jkatz) @ 2025-01-11 02:46 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> This guc wouldn't be defined in pgvector, but pgvector would check if it's set (just by name) and act accordingly.
If the plan is to propose it upstream, this is likely a discussion for pgsql-hackers, but scoping it to approximate indexes seems fairly limited. The "larger" feature would be to selectively enable/disable indexes from scanning, which is another way of saying "hints", which is a topic with a very long history. Alternatively, you can use an extension like [pg_hint_plan](https://github.com/ossc-db/pg_hint_plan) to provide hints in queries to force avoiding using a particular index.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-11 13:26 "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: VoVAllen (@VoVAllen) @ 2025-01-11 13:26 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
https://stackoverflow.com/questions/6146024/is-it-possible-to-temporarily-disable-an-index-in-postgr...
@jkatz I mean `update pg_index set indisvalid = false where indexrelid = 'test_pkey'::regclass` to alter the index status instead of disabling all the index scan.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-14 22:28 "gwenshap (@gwenshap)" <noreply+gwenshap@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: gwenshap (@gwenshap) @ 2025-01-14 22:28 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Just to add another option: `hypopg` extension also allows for selective disabling of indexes.
Using a mature and well-tested extension is a better approach than directly updating catalog tables.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 15:28 "jkatz (@jkatz)" <noreply+jkatz@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: jkatz (@jkatz) @ 2025-01-15 15:28 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> https://stackoverflow.com/questions/6146024/is-it-possible-to-temporarily-disable-an-index-in-postgr... @jkatz I mean `update pg_index set indisvalid = false where indexrelid = 'test_pkey'::regclass` to alter the index status instead of disabling all the index scan.
This is quoted from a StackOverflow post 14 years ago, and it's still not considered a safe operation (at least the last time I talked to PostgreSQL hackers who work on indexes on this topic). The mechanism for concurrent index building is different than the ongoing maintenance required for an index.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 15:29 "jkatz (@jkatz)" <noreply+jkatz@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: jkatz (@jkatz) @ 2025-01-15 15:29 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> Just to add another option: `hypopg` extension also allows for selective disabling of indexes. Using a mature and well-tested extension is a better approach than directly updating catalog tables.
@gwenshap Unless something has changed recently, `hypopg` doesn't let you explicitly disable an index, but rather shows the theoretical cost/performance of using an index.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 17:43 "cevian (@cevian)" <noreply+cevian@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: cevian (@cevian) @ 2025-01-15 17:43 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@jkatz the GUC it wouldn't need to be define upstream. You can have have custom gucs named whatever you want (as long as they have a period). Thus, all we need is a convention: we can use `plan.enable_approxscan` or something. That doesn't need to be pre-define anywhere ahead of time.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 17:57 "gwenshap (@gwenshap)" <noreply+gwenshap@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: gwenshap (@gwenshap) @ 2025-01-15 17:57 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> @gwenshap Unless something has changed recently, `hypopg` doesn't let you explicitly disable an index, but rather shows the theoretical cost/performance of using an index.
@jkatz Good point. It lets you hypothetically hide a real index and see the change to the plan. But the index will still get used when executing the query (as seen with `explain analyze`)
For reference: https://hypopg.readthedocs.io/en/rel1_stable/usage.html#hypothetically-hide-existing-indexes
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 20:01 "ankane (@ankane)" <noreply+ankane@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: ankane (@ankane) @ 2025-01-15 20:01 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @cevian, thanks for the suggestion. I've considered adding `hnsw.enable_scan` and `ivfflat.enable_scan` options to support this, but since there are already ways to do this (`+ 0` to `ORDER BY` or pg_hint_plan), it's not something I'd like to add right now.
^ permalink raw [nested|flat] 12+ messages in thread
* Re: [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option
@ 2025-01-15 20:01 "ankane (@ankane)" <noreply+ankane@github.com>
10 siblings, 0 replies; 12+ messages in thread
From: ankane (@ankane) @ 2025-01-15 20:01 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 12+ messages in thread
end of thread, other threads:[~2025-01-15 20:01 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-01-10 19:17 [pgvector/pgvector] issue #756: consider supporting an `enable_approxscan` option "cevian (@cevian)" <noreply+cevian@github.com>
2025-01-10 19:32 ` "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
2025-01-11 02:42 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-01-11 02:46 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-01-11 13:26 ` "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
2025-01-14 22:28 ` "gwenshap (@gwenshap)" <noreply+gwenshap@github.com>
2025-01-15 15:28 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-01-15 15:29 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-01-15 17:43 ` "cevian (@cevian)" <noreply+cevian@github.com>
2025-01-15 17:57 ` "gwenshap (@gwenshap)" <noreply+gwenshap@github.com>
2025-01-15 20:01 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-01-15 20:01 ` "ankane (@ankane)" <noreply+ankane@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