"Simon Stanlake" <stanlake@hi.ca> writes:
> can anyone tell me what slowed down the first query?
Well, the first one is going to scan (backwards) in datetimestamp order
until it finds a row with unitid = 2. The second one is going to use
the unitid index to pick out just the rows with unitid = 2, and then
sort them by timestamp. Depending on how many rows have unitid = 2
and how new the latest one is, I could see either of these being way
faster than the other.
regards, tom lane