`_creationTime` not guaranteed to be monotonic over time
Hi, guys, I've maybe come across a bug about convex. Please read the image.
4 Replies
Hi @Tsang, this is known and expected behavior. Here’s some more info on why this is the case and how you can achieve this behavior yourself, if you’d like to: https://discord.com/channels/1019350475847499849/1156626929684848650/1156637432951885836
OK, I'll check it out later
Now I add an index for the field called "statusUpdatedAt", and do the descending order on it rather than on the _creationTime, which solves my problem now.
So, I'd like to know whether it's not a very good practice to do descending order on the _creationTime field if the order of data really matters. @RJ
I can't really answer that for you without understanding your exact use case. If by "really matters" you mean that you must, always be able to determine each row's insert order, then you should take an approach like that described in the post I linked above:
for example, if you have a messages table, you could add a messageNumber field with an index on it. then, when inserting a message, you can query for the message with the highest message number and insert with one plus that, if present. then, you can be guaranteed that messageNumber is strictly monotonically increasing across different messages.
OK. I see. Thank you.