Skip to content
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

Reduce the number of indexes in o_* collections #66

Closed
gkubisa opened this issue Jul 24, 2018 · 1 comment
Closed

Reduce the number of indexes in o_* collections #66

gkubisa opened this issue Jul 24, 2018 · 1 comment

Comments

@gkubisa
Copy link
Contributor

gkubisa commented Jul 24, 2018

ShareDB stores all operations in collections prefixed with o_. Currently those collections have 3 indexes: _id, documentId + version, src + seq. I think we could have only one index, on _id, which MongoDB always creates automatically.

To keep the most common queries fast, we'd need to update IDs of all operations to this format: <documentId>:<version>:<randomValue>. This way we would not need the separate compound index documentId + version.

The other compound index src + seq is used so rarely that I don't think it's worth having. The code currently using this index could be modified to take advantage of the _id index to reduce the number of docs that would need to be scanned.

@alecgibson
Copy link
Contributor

We've had a discussion about this and we agree about src + seq, but think that we can't combine documentId + version without left-padding version (because we need version range lookups). Left-padding feels a bit hacky and fragile, and documentId + version feels like a reasonable index to have, so we'll leave that one as is

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

No branches or pull requests

2 participants