| От | Mike G. |
|---|---|
| Тема | Which is more efficient? |
| Дата | |
| Msg-id | 20041217185201.GA13389@localhost.localdomain обсуждение исходный текст |
| Список | pgsql-performance |
Hi,
I have data that I am taking from 2 tables, pulling out specific columns and inserting into one table.
Is it more efficient to do:
a) insert into x
select z from y;
insert into x
select z from a;
b) insert into x
select z from y
union all
select z from a;
I have run both through explain.
a) 650ms
b) 741.57ms
According to the planner option a, select z from y takes 545.93 ms
Under option b select z from y takes 553.34 ms
Shouldn't the time predicted for the select z from y be the same?
I would believe b would be more efficient as the inserts could be done in a batch rather than individual transactions
butthe planner doesn't recognize that. When I run option a through the planner I have to highlight each insert
separatelysince the planner stops executing after the first ; it comes across.
Mike
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера