Jeff Frost <jeff(at)frostconsultingllc(dot)com> writes:
> [ umpteen million iterations of: ]
> -> Limit (cost=0.00..367.09 rows=1 width=8)
> -> Index Scan Backward using page_view_stamp_idx on page_view pv2 (cost=0.00..158215.86 rows=431 width=8)
> Index Cond: (stamp < $1)
> Filter: ((stamp IS NOT NULL) AND (visit_id = $0))
Perhaps an index on (visit_id, stamp) would help. This one is doing the
best it can, but if the visit_id's you want are thinly scattered, it'll
still suck...
regards, tom lane