Max size of entity.key.id() > uint64

149 views
Skip to first unread message

Jay Kyburz

unread,
Jul 5, 2016, 7:41:36 PM7/5/16
to Google App Engine
Hey all, 

Today I'm integrating our app into the Steam store and I would like to use an entity's key.id() as an "orderid" which must be less than a uint64. 

Anybody know what the maximum number an entity's id can be when automatically generated?

Jay Kyburz

unread,
Jul 5, 2016, 7:52:11 PM7/5/16
to Google App Engine

Nicholas (Google Cloud Support)

unread,
Jul 6, 2016, 2:57:57 PM7/6/16
to Google App Engine
According to How Entities and Indexes are Stored under Id sequences table, generated numerical datastore IDs are 64-bit integers (signed is the assumption as it is not stated otherwise).  This would suggest the maximum value would be 9,223,372,036,854,775,807.  The Entities, Properties, and Keys article however, suggests under Assigning identifiers that generated IDs can be up to 16 decimal digits long.  Thus, the limit would be slightly smaller at 9,999,999,999,999,999.

Hope this helps make informed decisions about the use/reuse of IDs in your entities.

Jay Kyburz

unread,
Jul 6, 2016, 6:34:43 PM7/6/16
to Google App Engine
Thanks very much Nicholas, very helpful.

I would say the 16 digit rules apply to the auto generated ids as I dont see any larger on our entities.  

Joe White

unread,
Jul 6, 2016, 10:06:01 PM7/6/16
to Google App Engine
<opinion>
A long time ago, in a far far far away place, programmers decided to save storage by using a two-digit representation of the year in dates. In retrospect, not a great decision.

I would suggest that you not consider tying a required orderid to another implementation's keyid ... something may change in the future that could break the implied contract between two completely different systems that you make.

Your choice, of course, but I would not attempt to "optimize" in this way.
</opinion>


On Tuesday, July 5, 2016 at 7:41:36 PM UTC-4, Jay Kyburz wrote:

Nicholas (Google Cloud Support)

unread,
Jul 7, 2016, 9:28:18 AM7/7/16
to Google App Engine
Joe makes an excellent point for being future ready!  If your orderid field has very specific requirements to conform to, it may be best to simply store it in its own field where you can decide its type rather than a generated field whose type may change as the product evolves.


On Tuesday, July 5, 2016 at 7:41:36 PM UTC-4, Jay Kyburz wrote:
Reply all
Reply to author
Forward
0 new messages