-
Notifications
You must be signed in to change notification settings - Fork 2k
[ENH] Add index on database_id, name on collections table in sysdb #5102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
|
Add Index on (database_id, name) to collections Table in sysdb This PR introduces a new unique index on the collections table in the sysdb database for the columns (database_id, name). The change is part of a two-step migration to optimize collection listing queries by shifting the index order, which currently leads to full table scans when filtering by database_id. Key Changes• Added migration file to create a unique index on (database_id, name) for the collections table. Affected Areas• Database schema (collections table) This summary was automatically generated by @propel-code-bot |
eeaff88 to
d11ffa6
Compare
d11ffa6 to
c1aa8f5
Compare
## Description of changes This PR drops a previous on the collections table for name, database_id in favor of a new index on database_id, name that was merged here #5102 ## Test plan _How are these changes tested?_ - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan _Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?_ ## Observability plan _What is the plan to instrument and monitor this change?_ ## Documentation Changes _Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_
…hroma-core#5102) ## Description of changes This PR adds a new index on the collections table on (databse_id, name). This is the first of 2 PRs to remove the existing index on (name, database_id). This is because list collections does a full table scan on collections to filter where database_id matches. By moving the index to database_id first, it supports both the list_collection use case of indexing on database_id, while maintaining the index which is useful for get_collection (which indexes on name and database id) before: <img width="720" height="249" alt="image" src="https://github.com/user-attachments/assets/adb5f088-e40c-4202-8d5f-bd5cfbe0d7b2" /> after: <img width="720" height="216" alt="image" src="https://github.com/user-attachments/assets/e091865f-03da-4b7c-b8f0-504cbc437e48" /> ## Test plan _How are these changes tested?_ - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan _Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?_ ## Observability plan _What is the plan to instrument and monitor this change?_ ## Documentation Changes _Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_
## Description of changes This PR drops a previous on the collections table for name, database_id in favor of a new index on database_id, name that was merged here chroma-core#5102 ## Test plan _How are these changes tested?_ - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan _Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?_ ## Observability plan _What is the plan to instrument and monitor this change?_ ## Documentation Changes _Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_

Description of changes
This PR adds a new index on the collections table on (databse_id, name). This is the first of 2 PRs to remove the existing index on (name, database_id). This is because list collections does a full table scan on collections to filter where database_id matches. By moving the index to database_id first, it supports both the list_collection use case of indexing on database_id, while maintaining the index which is useful for get_collection (which indexes on name and database id)
before:

after:

Test plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustMigration plan
Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?
Observability plan
What is the plan to instrument and monitor this change?
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?