Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

What data structure does Firestore use for its indexes?

is it b-tree? LSM tree? something else?

Solved Solved
0 1 334
1 ACCEPTED SOLUTION

Though not entirely the same, Firestore indexes are built in a similar way as Datastore indexes. Datastore indexes and the data in your entities are stored in BigTable (a wide column database). As explained in a Google Cloud Next conference, indexes are stored in a separate table, in which Kind (or collection) indexes are mapped to a sorted column of the indexed property. The key of an entity (or document id) is also mapped to the indexed property, to point to the corresponding entity (Entities are stored in their own table).  

For composite indexes, the same process follows, but this time the specific arrangement of the properties indexed are stored in a table, with the matching Entity key and Kind key mapped to it. If you would like to know more about BigTable internals, as well as for Megastore (a storage system to support transactions), you can read the published research papers for BigTable and Megastore.

View solution in original post

1 REPLY 1

Though not entirely the same, Firestore indexes are built in a similar way as Datastore indexes. Datastore indexes and the data in your entities are stored in BigTable (a wide column database). As explained in a Google Cloud Next conference, indexes are stored in a separate table, in which Kind (or collection) indexes are mapped to a sorted column of the indexed property. The key of an entity (or document id) is also mapped to the indexed property, to point to the corresponding entity (Entities are stored in their own table).  

For composite indexes, the same process follows, but this time the specific arrangement of the properties indexed are stored in a table, with the matching Entity key and Kind key mapped to it. If you would like to know more about BigTable internals, as well as for Megastore (a storage system to support transactions), you can read the published research papers for BigTable and Megastore.