When a write is performed, does the database write the entities in some kind of order by their key?
For example, if I have written following keys (intentionally keeping the name
(1, 7, 3) out of sequence):
["A", "1"]
["A", "7"]
["A", "3"]
Would a query on the Kind A
with no filters or ordering return the results as:
["A", "1"]
["A", "3"]
["A", "7"]
Maybe even more to the point if my keys contained a timestamp (milliseconds as the name):
["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872201000"]
["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872207000"]
["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a", "UserRecord", "1597872203000"]
Would a query on
("UserRecord").hasAncestor(["UserSession", "e4facf67-969d-46f5-b922-390f61beac0a"])
return the objects sorted by their name (aka timestamp in milliseconds)?
Yes, Cloud Firestore in Datastore mode does store entities in key order. You can see this from the best practices document which says:
If you assign your own manual numeric ID or custom name to the entities you create, do not use monotonically increasing values
If an application generates large traffic, such sequential numbering could lead to hotspots that impact Datastore mode latency.