Re:You might as well timestamp it
by RedShift1 on Saturday April 24, 2021 @09:10AM
(#26924605)
Storing both boolean and timestamp with the correct constraints seems like a better solution to me.
[ Parent
| on HN ]
This is the typical solution for MySQL. There are indexable virtual generated columns but don't seem to have been used/around enough to be battle tested.
Using just the nullable timestamp only lets you index on one of the boolean states: an index on (ts, col2) works for WHERE ts IS NULL ORDER BY col2, but WHERE ts IS NOT NULL ORDER BY col2 doesn't work well (without using generated boolean, etc).