how is the primary key determined

0
Does the Mendix runtime query the table before insertion to get the latest id, or is there a sequence of some sort in one of the tables?
asked
1 answers
1

Since Mendix 4, we obtain unique ids in batches. This means that objects can be created without querying the database at that very moment, resulting in better performance. When running low on ids to hand out, we obtain some more.

For every entity we have a row with the current object sequence number in a table called mendixsystem$entityidentifier, the column is called object_sequence.

The Modeler creates a 128 bit GUID for each entity that uniquely defines it in the world, for example so appstore modules can be inserted without conflicts. This is the ID column in your screenshot. The Runtime creates a short_id for this identifier as we don't need such a long number in a single database.

Each 64 bit identifier of an object consists of 16 (most significant) bits of the entity short id and 48 (least significant) bits of the object sequence number. In your example image, the next object that would be created for the first entity in the list would have the number 28 in the first 16 bits and the number 201 in the next 48 bits. This would result in the identifier 7881299347898569.

answered