Re: Using indices for UNION.
От | Tom Lane |
---|---|
Тема | Re: Using indices for UNION. |
Дата | |
Msg-id | 25104.1396640187@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Using indices for UNION. (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Using indices for UNION.
|
Список | pgsql-hackers |
I wrote: > However, it's not clear to me that this is worth the trouble. The > DISTINCT would act as an optimization fence preventing the subquery from > being flattened any further, so it doesn't seem like there would be any > global benefit just because it now contains a simple appendrel rather than > a setop tree. And a nest of conversion-free UNIONs already results in a > plan that's a flat Append followed by sort/uniq, which seems like the same > thing you'd get from the DISTINCT. So what's the point? Oh, after re-reading the earlier part of the thread I get the point --- after making this change, the planner will consider some plan types for the DISTINCT that it wouldn't have found in the setop-tree planning path. Specifically it can make use of a mergeappend of sorted paths for the individual union leaf queries. That can't happen in the generic setop planning code because we have no ability to consider more than one plan for any leaf query. I still think this stuff mostly needs to be thrown away and rewritten in Path-creation style, but that's a long-term project. In the meantime this seems like a relatively small increment of complexity, so maybe it's worth applying. I'm concerned about the method for building a new DISTINCT clause though; the best that can be said for that is that it's a crude hack, and I'm less than convinced that there are no cases where it'll dump core. regards, tom lane
В списке pgsql-hackers по дате отправления: