3 ms·
Storing both boolean and timestamp with the correct constraints seems like a better solution to me.
by RedShift1 6y ago
Storing both boolean and timestamp with the correct constraints seems like a better solution to me.
- karmakaze 6y agoThis 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).