How are Long ids used in Google Datastore insert/update queries?

1 view
Skip to first unread message

Askar via StackOverflow

unread,
May 12, 2017, 4:33:04 PM5/12/17
to gcd-stac...@googlegroups.com

I do not think you need to worry about uniqueness of your id. Datastore build on top of Bigtable with 6 tables.

  1. first table stores entities
  2. second stores entities by kind
  3. third stores indexes for the property values in the ascending order
  4. fourth to store indexes for the property values in the descending order
  5. fifth stores indexes for multiple properties together
  6. sixth keeps a track of the next unique ID for Kind

Format is something like this. [application ID]-[namespace]-[Kind]-[ID]

It is garanties of uniqueness each entities.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/43930529/how-are-long-ids-used-in-google-datastore-insert-update-queries/43945996#43945996

Askar via StackOverflow

unread,
May 14, 2017, 8:53:07 PM5/14/17
to gcd-stac...@googlegroups.com

I do not think you need to worry about uniqueness of your id. Datastore build on top of Bigtable with 6 tables.

  1. first table stores entities
  2. second stores entities by kind
  3. third stores indexes for the property values in the ascending order
  4. fourth to store indexes for the property values in the descending order
  5. fifth stores indexes for multiple properties together
  6. sixth keeps a track of the next unique ID for Kind

Format is something like this. [application ID]-[namespace]-[Kind]-[ID]

It is garanties of uniqueness each entities.

Yes, the format on that table is [Application ID]-[Kind Name] and the value is the next value. Let say you have kind products and that table will look like this |key(yourapp-products), Next ID(3)|. Now you created new entity for kind products it will be assigned to ID(3) and the row on that table will get new value |key(yourapp-products), Next ID(4)|. Also to mention that table has only one row since we have only one kind products.

Do you specify ID yourself or let datastore generate itself? It sounds like you have "Pre-allocating IDs" issue, just speculating but for every batch you need sort Kind.allocate_ids(size=blah) that way you can keep sequence.

Reply all
Reply to author
Forward
0 new messages