We are experiencing a strange problem with triggers and a sequence generator in Postgres. We have a trigger on table that inserts audit log informations (some business Data before update, some business Data after update, ...).
The problem we have is that the order of the sequence generated doesn't match the timestamp and the data at the time of the capture.
We are sure that functionnaly the row with the id (7 228 916) happened after the row with the id (7 229 471), as the timestamps confirm it.
But the sequences are not in the correct order.
At the end of the of the trigger, here is the insert statement:
INSERT INTO AUDIT_TABLE (ID, ROW_ID, CREATED_AT, ...)
VALUES (nextval('AUDIT_TABLE_SEQ'), NEW.PK_, current_timestamp, ...);
Does someone please have an explanation for this problem?
Thank you for your help
We are expecting to have the sequences to be ordered with timestamps of the capture of events.