=?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