To be fair, it's understandable that postgres doesn't know that extract(epoch from ts) does not change the order of m.ts.
For postgres, it's just a random function which could do anything, I guess. So it can't use the index since it needs to calculate that value for every row first. To spot stuff like this is part of my job as a developer :)
extract(epoch from ts)
does not change the order ofm.ts
. For postgres, it's just a random function which could do anything, I guess. So it can't use the index since it needs to calculate that value for every row first. To spot stuff like this is part of my job as a developer :)