I need to have a number that generally increases with every request made to 
the service. The only requirement is that it is strictly monotonous - I 
don't need a specific start, and I don't care if there are any holes.

Possible solutions: 

- just use request.utcnow -- seems to satisfy, but I've seen clocks go back 
on machines (if time is off by more than one minute, ntpd just resets it 
rather an try to modify clock speed), so I don't want to rely on that one.

- Insert a record into a dummy table, and use the last-row-id of the dummy 
record. Occasionally, (e.g. in a batch job) delete every record except the 
last. (Or maybe including the last? do all dbs supported maintain a sequence 
counter independent of the current maximum value of a column?)

Is there a simpler solution I am overlooking? 

The use case for this is for mutually synchronizing database; I add a 
"updtime" field to every record in every table, and then when I want to 
efficiently tell what records have been inserted or updated in a table, I 
just look for those with updtime larger than the update time of the previous 
sync. Time would generally work for this, except -- as mentioned above -- it 
is hard to guarantee that system time never goes backwards.

Reply via email to