Odd Hogstad <odd(dot)hogstad(at)smartm(dot)no> writes:
> I need to get the latest entry of a large table matching a certain criteria.
> This is my query:
> SELECT * FROM "data" WHERE "data"."fk" = 238496 ORDER BY "data"."id" DESC
> LIMIT 1
A two-column index on (fk, id) would help for this. If you think about
the ordering of the index entries you'll see why.
regards, tom lane