Re: Improvement for query planner? (no, not about count(*) again ;-))

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Improvement for query planner? (no, not about count(*) again ;-))
Дата
Msg-id 578634.1595267899@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Improvement for query planner? (no, not about count(*) again ;-))  (Tobias Völk <tobias.voelk@t-online.de>)
Ответы Re: Improvement for query planner? (no, not about count(*) again ;-))  (Andres Freund <andres@anarazel.de>)
Список pgsql-bugs
=?utf-8?Q?Tobias_V=C3=B6lk?= <tobias.voelk@t-online.de> writes:
> I’ve asked postgres to make an unlogged newtable(name text primary key) consisting of the unqiue names and executed:

> Insert into newtable(name) select name1 from games on conflict do nothing;

ON CONFLICT is a really, really expensive way to eliminate duplicates.
It's meant to handle situations where two or more sessions might
concurrently insert duplicate keys, which means that (a) there's not
really any way to detect the situation in advance or optimize it,
and (b) we don't expect it to happen that much anyhow.

You'd be better off with something like

insert into newtable(name) select distinct name1 from games;

or

insert into newtable(name) select name1 from games group by name1;

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jehan-Guillaume de Rorthais
Дата:
Сообщение: Re: Buffers from parallel workers not accumulated to upper nodes with gather merge
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Improvement for query planner? (no, not about count(*) again ;-))