@@ -21,21 +21,25 @@ class PgVectorConfigDict(TypedDict):
21
21
22
22
23
23
class PgVectorConfig (DBConfig ):
24
- user_name : SecretStr = SecretStr ( "postgres" )
24
+ user_name : SecretStr = "postgres"
25
25
password : SecretStr
26
26
host : str = "localhost"
27
27
port : int = 5432
28
- db_name : str
28
+ db_name : str = "vectordb"
29
+ table_name : str = "vdbbench_table_test"
29
30
30
31
def to_dict (self ) -> PgVectorConfigDict :
31
- user_str = self .user_name .get_secret_value ()
32
+ user_str = self .user_name .get_secret_value () if isinstance ( self . user_name , SecretStr ) else self . user_name
32
33
pwd_str = self .password .get_secret_value ()
33
34
return {
34
- "host" : self .host ,
35
- "port" : self .port ,
36
- "dbname" : self .db_name ,
37
- "user" : user_str ,
38
- "password" : pwd_str ,
35
+ "connect_config" : {
36
+ "host" : self .host ,
37
+ "port" : self .port ,
38
+ "dbname" : self .db_name ,
39
+ "user" : user_str ,
40
+ "password" : pwd_str ,
41
+ },
42
+ "table_name" : self .table_name ,
39
43
}
40
44
41
45
@@ -59,6 +63,10 @@ class PgVectorIndexConfig(BaseModel, DBCaseConfig):
59
63
metric_type : MetricType | None = None
60
64
create_index_before_load : bool = False
61
65
create_index_after_load : bool = True
66
+ # Scan more of the index to get enough results for filter-cases.
67
+ # Options: "strict_order" (order by distance), "relaxed_order" (slightly out of order but better recall)
68
+ # See: https://github.com/pgvector/pgvector?tab=readme-ov-file#iterative-index-scans
69
+ iterative_scan : str = "relaxed_order"
62
70
63
71
def parse_metric (self ) -> str :
64
72
d = {
@@ -205,7 +213,7 @@ def search_param(self) -> PgVectorSearchParam:
205
213
}
206
214
207
215
def session_param (self ) -> PgVectorSessionCommands :
208
- session_parameters = {"ivfflat.probes" : self .probes }
216
+ session_parameters = {"ivfflat.probes" : self .probes , "ivfflat.iterative_scan" : self . iterative_scan }
209
217
return {"session_options" : self ._optionally_build_set_options (session_parameters )}
210
218
211
219
@@ -255,7 +263,7 @@ def search_param(self) -> PgVectorSearchParam:
255
263
}
256
264
257
265
def session_param (self ) -> PgVectorSessionCommands :
258
- session_parameters = {"hnsw.ef_search" : self .ef_search }
266
+ session_parameters = {"hnsw.ef_search" : self .ef_search , "hnsw.iterative_scan" : self . iterative_scan }
259
267
return {"session_options" : self ._optionally_build_set_options (session_parameters )}
260
268
261
269
0 commit comments