Search code examples
google-cloud-firestoregoogle-cloud-datastore

Is it safe to use UUIDs as keys in Google Cloud Firestore in Datastore Mode?


I've read that when setting custom keys in Google Cloud Firestore in Datastore Mode, it's important to avoid using monotonically increasing IDs as these could lead to hotspots.

Allowing Google to generate the IDs would avoid this problem.

However, I would like to set my own IDs by generating a UUID for each entity. Is this approach likely to lead to the hotspotting problems described in the article? Or would the entropy in a UUID mean that entities are likely to be well distributed throughout the keyspace?


Solution

  • If it's a standard random UUID, it will have more than enough entropy.