| От | Adam Rich |
|---|---|
| Тема | Re: Overhead of union versus union all |
| Дата | |
| Msg-id | 4A564F0B.9090201@sbcglobal.net обсуждение исходный текст |
| Ответ на | Overhead of union versus union all (Tim Keitt <tkeitt@keittlab.org>) |
| Список | pgsql-general |
Tim Keitt wrote: > I am combining query results that I know are disjoint. I'm wondering > how much overhead there is in calling union versus union all. (Just > curious really; I can't see a reason not to use union all.) (cc me > please; not subscribed...) > > THK > I think you can test this one yourself pretty easily. Just run the two queries with "explain analyze". Union All should run in about the sum of the separate queries. Plain Union will always be slower, because it takes the same results from "union all" and runs them through an extra sort/distinct or hash step. In my tests, on a query with 600,000 rows, the Plain Union took about 3x as long to complete.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера