Skip to content

Conversation

@jairad26
Copy link
Contributor

@jairad26 jairad26 commented Jul 14, 2025

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:
image

after:
image

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?

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@jairad26 jairad26 marked this pull request as ready for review July 14, 2025 21:00
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Jul 14, 2025

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.
• Updated the migration checksum in atlas.sum to reflect the new migration.

Affected Areas

• Database schema (collections table)
• Migration files

This summary was automatically generated by @propel-code-bot

@jairad26 jairad26 enabled auto-merge (squash) July 14, 2025 22:12
@jairad26 jairad26 force-pushed the jai/update-collection-index branch from eeaff88 to d11ffa6 Compare July 14, 2025 23:30
@jairad26 jairad26 force-pushed the jai/update-collection-index branch from d11ffa6 to c1aa8f5 Compare July 15, 2025 00:11
@jairad26 jairad26 merged commit f80938f into main Jul 15, 2025
58 checks passed
jairad26 added a commit that referenced this pull request Jul 16, 2025
## 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)?_
Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
…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)?_
Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
## 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)?_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants