Extract newly created records via ODATA - Mendix Forum

Extract newly created records via ODATA


I need to extract entities out of my Mendix applications. I expose my entity via OData and extract the table. The next time I do an extract from the entity, I want to extract only newly created records. Can I rely on the internal ID column to do so? I.e. I record the largest ID from the previous call, and make the next OData call asking for records with higher ID values. Something like below. 


The call seems to be doing the job. Can I rely on ID column?

P.S. I would really hate to create an autonumber column in each entity purely because I need to extract data out of those entities.

2 answers

The algorithm for generating Mendix IDs does increment only in an ascending order. However, I think the ID column has a similar issue to the createDate. Mendix runtimes pre-reserve a set of IDs ahead of time for each entity, so if you have more than 1 runtime (horizontal scaling) then IDs could potentially be committed out of order.


You should not rely on the ID, especially if you run multi-instance. Each runtime caches 100 ids, and them assigns them as needed. This means that the following record ids can be inserted into your entities in this sequence: 1,2,100,101,3,4,102,104. Now, if  halfway you query the new records by selecting everything above 101, you will never receive id 3 & 4.