Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can dates can be considered monotonically in Firestore?

I read here that:

Do not use monotonically increasing document IDs such as:

Customer1, Customer2, Customer3, ...
Product 1, Product 2, Product 3, ...

I plan to use document IDs such:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

2023-09-01, 2023-09-02, 2023-09-07, ...

The dates are not always consecutive. It can be or cannot be. Can be these dates be considered monotonically?

>Solution :

Yes. Any time you have a series of sorted values that increment over a small range, that is considered monotonically increasing for the purpose of gauging the write rate limit for indexes in Firestore. This is because they will all cause writes on the same shard of the index that handles that range of values.

Also I would strongly urge you not to use data as document IDs. It’s better to use random IDs, and create an index on the timestamp values instead, if you need to sort and filter on them. This will prevent other future problems with your app when you need to change the schema or the way you organize data.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading