mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 03:28:22 +00:00
fix(db): persist hnsw.iterative_scan via ALTER DATABASE instead of SET
SET only applies to the current migration session and is lost when the
connection closes. Use a DO block with current_database() to execute
ALTER DATABASE ... SET, which persists the GUC for all future connections.
The DO block with format('%I', current_database()) avoids hardcoding
the database name and works on PostgreSQL < 16 (which lacks ALTER DATABASE
CURRENT syntax).
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
-- Enable iterative index scans for HNSW so filtered queries don't fall back to seq scan
|
||||
SET hnsw.iterative_scan = relaxed_order;
|
||||
-- Enable iterative index scans for HNSW so filtered queries don't fall back to seq scan.
|
||||
-- Uses current_database() so this works across all environments without hardcoding the DB name.
|
||||
-- ALTER DATABASE ... SET persists the GUC for all future connections to this database.
|
||||
DO $$
|
||||
BEGIN
|
||||
EXECUTE format('ALTER DATABASE %I SET hnsw.iterative_scan = ''relaxed_order''', current_database());
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- CreateIndex: HNSW index on asset_embeddings.embedding
|
||||
-- Uses cosine distance ops (suited for normalized OpenAI-style embeddings)
|
||||
|
||||
Reference in New Issue
Block a user