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

An incremental step to an "embedded" implementation #706

Open
danielballan opened this issue Jun 13, 2022 · 2 comments
Open

An incremental step to an "embedded" implementation #706

danielballan opened this issue Jun 13, 2022 · 2 comments

Comments

@danielballan
Copy link
Member

Status Quo

We encode Bluesky documents directly into MongoDB documents. There is one MongoDB collection per document type, and each Bluesky document becomes one MongoDB document. The MongoDB representation picks up an additional internal key (_id) that is used internally but not exposed by Databroker.

This system has the benefit of being conceptually straightforward. But it has disadvantages:

  • Loading a Run requires at least three database hits (start, stop, descriptors).
  • MongoDB does not support anything like a database join. This makes it impossible to efficiently support queries on anything in 'stop' or 'descriptor' documents. We would be forced to query on start (to filter for access control) and then either do a join or a filter in Python.

Approaches considered and attempted

We considered two approaches:

  1. Consolidate "header" Bluesky documents into one MongoDB document. Consolidate 'event' and 'datum' documents into paged representations. This is what is implemented, but not yet thoroughly tested, in the mongo_embedded implementation in suitcase_mongo.
  2. Consolidate "header" Bluesky documents into one MongoDB document. Store 'event' and 'datum' documentation using a different, column-oriented, technology. This is what we planned to do after mongo_embedded was validated.

New proposal

Years on from that decision, I think we should have separate the changes to "header" documents and the change to 'event' and 'datum' documents. Appending chunks of paged 'event' and 'datum' documents added a lot of complexity, and I think it's arguable whether the effort to make this work in MongoDB was worthwhile. But consolidating 'start', 'stop', and 'descriptor' documents into one MongoDB document is completely straightforward and would advance the kinds of queries we can run efficiently.

A simple migration tool could look for 'start', 'stop', and 'descriptor' collections and consolidate their contents into a new 'header' collection. This would be safe to run multiple times if some writers take more time to switch to the new writing schema.

Then, having done that, we can separately consider whether to switch to a mongo_normalized approach with 'event' and 'datum' or to move them to a separate column-based technology.

@gwbischof
Copy link
Contributor

I like this idea!
Could we take a minute to brainstorm names for the new header document type?

@danielballan
Copy link
Member Author

Can you list some ideas here? My opening suggestion is header or bluesky_header_v1.

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