Skip to content

Commit a804318

Browse files
committed
Add indexes HNSW and IVFFLAT
1 parent 3cf4a7b commit a804318

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pgvector-module/src/main/kotlin/griffio/grammar/pgvector.bnf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,16 @@ extension_expr ::= distance_operator_expression | {double_colon_cast_operator_ex
6767
implements = "app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlExtensionExpr"
6868
override = true
6969
}
70+
71+
index_method ::= 'BRIN' | 'BTREE' | 'GIN' | 'GIST' | 'HASH' | 'HNSW' | 'IVFFLAT' {
72+
extends = "app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlIndexMethodImpl"
73+
implements = "app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlIndexMethod"
74+
override = true
75+
}
76+
77+
storage_parameters ::= 'autosummarize' | 'buffering' | 'deduplicate_items' | 'fastupdate' | 'fillfactor' | 'gin_pending_list_limit' | 'pages_per_range' | 'lists' {
78+
extends = "app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlStorageParameterImpl"
79+
implements = "app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlStorageParameter"
80+
override = true
81+
}
82+

src/main/sqldelight/griffio/migrations/V1__Initial_version.sqm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ CREATE TABLE items (
33
embedding VECTOR(3)
44
);
55

6+
CREATE INDEX idx_embedding_hnsw ON items USING hnsw (embedding vector_l2_ops);
7+
8+
CREATE INDEX idx_embedding_ivfflat ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100);

0 commit comments

Comments
 (0)