---
feature_story: FS_56_43_05_79
feature_title: search diff collection
feature_status: TODO
---

At the moment, `argrelay` server uses [single Mongo DB collection for all objects][single_mongo_collection].

Server:
*   cleans this single collection completely and populates all `data_envelope`-s on start,
*   keeps using that single collection for all searches while alive.

It works fine for small data sets, but adds extra latency (observable with `mongomock`) for large ones.

The idea is to add a special attribute/key to all `data_envelope`-s indicating collection they belong to:
*   Server will inspect this attribute to select which collection it is supposed to be stored in.
*   Selected function will provide information in `search_control` which collection specific `data_envelop` has to be searched in.

This will avoid the hardest limitation of MongoDB (not applicable for `mongomock`):
number of indexes per collection = 64
https://www.mongodb.com/docs/manual/reference/limits/#mongodb-limit-Number-of-Indexes-per-Collection
See: `test_MongoClient_index_limits.py`

This will also reduce latency in for seemingly non-important use cases with `mongomock` instead of real Mongo DB.
But `mongomock` is expected to be the default choice (majority of installations).

It also enables us to set up different handling for different collections.
Some of them might be too big to re-populate on re-start (too long).

[single_mongo_collection]: https://github.com/argrelay/argrelay/blob/f4c6a6fb9e5cb1226137c3744dd71693ae12c051/src/argrelay/mongo_data/MongoClientWrapper.py#L32
