Gordan Bobic <gordan@bobich.net> writes:
> And is the overhead of running multiple UNION queries greater than the
> overhead of doing a DISTINCT? I need to sort the records anyway, so the fact
> that DISTINCT does a SORT is a bonus in this case.
UNION implies DISTINCT, so you're going to get sort and uniq steps in
either case. What this is really going to boil down to is how the
restriction and join steps are done, and you haven't given enough info
to speculate about that. Try some experimentation with EXPLAIN to see
what kinds of plans you get.
regards, tom lane