I have a Rails 2.3.5 application with a table containing id and created_at columns. The table captures state changes for entities over time, so I sometimes use it to search for the state of an object at a specific time, by searching for state changes that occurred before time, and selecting the latter according to the created_at timestamp. For 10 out of 1445 objects, timestamps of state changes are in a different order by identifiers, and the state of the last state change is different from the state that is stored with the object itself, for example.
id | created_at | entity_id | state |
------+---------------------+-----------+-------+
1151 | 2009-01-26 10:27:02 | 219 | 1 |
1152 | 2009-01-26 10:27:11 | 219 | 2 |
1153 | 2009-01-26 10:27:17 | 219 | 4 |
1154 | 2009-01-26 10:26:41 | 219 | 5 |
I might get around this by ordering id instead of a timestamp, but I can't come up with an explanation of how this could happen. The application uses several instances of mongrel, but they are all located on the same machine (Debian Lenny); Am I missing something obvious? DB - Postgres.
source
share