Ave! Tom Lane wrote: >>trax=# explain select * from pakiety where stid = 234::smallint order by >>received desc limit 1; > > The reason this won't use the (stid, received) index is that the > requested sort order doesn't match that index. Try > > select * from pakiety where stid = 234::smallint > order by stid desc, received desc > limit 1; Thanks. It works. And the speedup was from 2 minutes 32.13 seconds to 0.69 seconds (in a worst case for the previous scenario). Thanks again for your help. Piotr Sulecki. ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match