Repository navigation
Check for a covering index using pg_catalog params, not ix name/string matching #81
Copy link
Copy link
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Currently vecs uses string pattern matching on the index name to determine if an index exists and supports the correct vector ops
Logic is here
Lines 623 to 677 in cc412ce
| def index(self) -> Optional[str]: | |
| """ | |
| PRIVATE | |
| Note: | |
| The `index` property is private and expected to undergo refactoring. | |
| Do not rely on it's output. | |
| Retrieves the SQL name of the collection's vector index, if it exists. | |
| Returns: | |
| Optional[str]: The name of the index, or None if no index exists. | |
| """ | |
| if self._index is None: | |
| query = text( | |
| """ | |
| select | |
| relname as table_name | |
| from | |
| pg_class pc | |
| where | |
| pc.relnamespace = 'vecs'::regnamespace | |
| and relname ilike 'ix_vector%' | |
| and pc.relkind = 'i' | |
| """ | |
| ) | |
| with self.client.Session() as sess: | |
| ix_name = sess.execute(query).scalar() | |
| self._index = ix_name | |
| return self._index | |
| def is_indexed_for_measure(self, measure: IndexMeasure): | |
| """ | |
| Checks if the collection is indexed for a specific measure. | |
| Args: | |
| measure (IndexMeasure): The measure to check for. | |
| Returns: | |
| bool: True if the collection is indexed for the measure, False otherwise. | |
| """ | |
| index_name = self.index | |
| if index_name is None: | |
| return False | |
| ops = INDEX_MEASURE_TO_OPS.get(measure) | |
| if ops is None: | |
| return False | |
| if ops in index_name: | |
| return True | |
| return False |
It would be preferable to lookup the supported ops in pg_catalog such that it is more intuitive
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Activity
KaranPradhan266 commentedon Dec 20, 2025
Hey @olirice — I’d love to work on this. I recently contributed to the Supabase stripe sync engine and would be excited to take a shot at this as well. Let me know if it’s still available to work on!
omwanere commentedon Jan 18, 2026
Hi 👋
I can take a look at this and update the index detection logic to use pg_catalog metadata instead of index name matching.
I’ll investigate and share a PR if I find a clean solution.