Skip to content

Commit

Permalink
scope index lookups to a table to remove singleton issue
Browse files Browse the repository at this point in the history
  • Loading branch information
olirice committed Jul 31, 2024
1 parent cc412ce commit a6a2aea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/vecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

__project__ = "vecs"
__version__ = "0.4.3"
__version__ = "0.4.4"


__all__ = [
Expand Down
18 changes: 12 additions & 6 deletions src/vecs/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Importing from the `vecs.collection` directly is not supported.
All public classes, enums, and functions are re-exported by the top level `vecs` module.
"""

from __future__ import annotations

import math
Expand Down Expand Up @@ -638,17 +639,22 @@ def index(self) -> Optional[str]:
query = text(
"""
select
relname as table_name
pi.relname as index_name
from
pg_class pc
pg_class pi -- index info
join pg_index i -- extend index info
on pi.oid = i.indexrelid
join pg_class pt -- owning table info
on pt.oid = i.indrelid
where
pc.relnamespace = 'vecs'::regnamespace
and relname ilike 'ix_vector%'
and pc.relkind = 'i'
pi.relnamespace = 'vecs'::regnamespace
and pi.relname ilike 'ix_vector%'
and pi.relkind = 'i'
and pt.relname = :table_name
"""
)
with self.client.Session() as sess:
ix_name = sess.execute(query).scalar()
ix_name = sess.execute(query, {"table_name": self.name}).scalar()
self._index = ix_name
return self._index

Expand Down

0 comments on commit a6a2aea

Please sign in to comment.