Kilian Hagemann <hagemann1@egs.uct.ac.za> writes:
>> - what version are you running?
> 7.4.8, not sure if I'm ready for 8 yet.
Pre-8.0 tends to underestimate the correlation of a multicolumn index.
(8.0 may too, but not as much.)
> Also, note that set_id is strictly increasing (hence correlation of 1) and
> rec_time is strictly increasing within records with same set_id.
So the reason the indexscan is so good is that the ordering correlation
is perfect. This isn't the planner's default assumption, and
unfortunately we haven't got statistics available that would allow
correlation of a multicolumn index to be estimated well.
regards, tom lane