Greg Mitchell <gmitchell(at)atdesk(dot)com> writes:
> I don't understand why it re-sorts the data even though the indexes are in
> the same order?
What are the available indexes exactly? It looks to me from the names
that the indexes probably *don't* match the sort order the merge is
using. What I'm wondering is whether the planner should be expected to
find a merge plan that adapts to the available indexes. In the light
of morning I doubt this has anything to do with custom data types at
all, but with the fact that the planner doesn't exhaustively search
through every possible combination of mergejoin conditions.
If you turn off enable_sort as well, does it find a sort-free merge
plan?
regards, tom lane