INF: MIN and MAX Should Not Be Used on Timestamp Column

ID Number: Q64559

1.00 1.10 1.11 4.20

OS/2

Summary:

MIN and MAX should not be used on timestamp columns to number rows

because MIN and MAX incorrectly assume the rightmost byte is the most

significant byte. Timestamps are actually incremented by assuming that

the rightmost byte is the least significant byte.

After 255 updates, MIN and MAX assume the value has changed from the

most positive value to the most negative value when the value really

only increased by one. If a technique such as the following is used to

number rows, all the rows with timestamps greater than the old

timestamp of the row that crossed the 255 boundary will be skipped:

select @current="",@n=0

select @cnt=count(*) from t1

while @n<@cnt begin

select @n=@n+1

select @current=min(timestamp) from t1 where key>@current

update t1 set rowcnt=@n where key=@current

Additional reference words: 1.00 1.10 1.11 4.20