Materials-Consortia / optimade-python-tools

Tools for implementing and consuming OPTIMADE APIs in Python
https://www.optimade.org/optimade-python-tools/
MIT License
66 stars 42 forks source link

Enforcing indexes on source DBs #292

Open shyamd opened 4 years ago

shyamd commented 4 years ago

One thing we don't do is enforce MongoDB indexes for performance in querying. We might want to think about how to at least suggest which indexes to create on, even if the server doesn't enforce them.

ml-evs commented 4 years ago

For odbx, I have an extended MongoEntryCollection class that takes a pymongo index model and creates the index if not present (see below). Currently I only do this for id by default (the underlying database has extra indexes). We could add this by default?

https://github.com/ml-evs/odbx.science/blob/c40fbb35f65e77d2aafde498a327baf9cab34a19/odbx/routers/structures.py#L30-L35