This is a very very noob and silly question but I can't seem to find what the following means in Postgres:
select *
from table
where (last_updated, id) > (timestamp with time zone '2019-03-28 23:30:22.496+00:00', 0)
Basically what does (last_updated, id) > (timestamp with time zone '2019-03-28 23:30:22.496+00:00', 0)
mean ? what's it comparing ? changing second value doesn't seem to have effects on the results for some reason.
Comparing tuples uses lexographical order, meaning that the second value is only used in case the first value ties.
So if your row has a timestamp of exactly that cutoff value, then the id needs to be greater than 0.
Hunch: This is used for cursor-based paging, where the second page starts off right after the last value on the first page (according to the sort criteria, here a timestamp), with id used as a tie-breaker (for when the last entry on the previous page and the first entry on the next page have the same sorting value --- probably unlikely for timestamps, but very likely if you order by salary or such).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With