Alban Hertroys <alban@xxxxxxxxxxxxxxxxx> writes: > Is there a trick to make this work a bit faster? Have you really shown us the right queries for those explain results? I don't see where the second plan is testing "dir <> 1" at all. It looks like the first one is faster because it's using a partial index that has predicate dir <> 1, while the second one is using a much larger full index. But I don't see where the second plan is applying that restriction, so I wonder if you forgot it in the query. regards, tom lane