why insert into UNLOGGED table WITH (autovacuum_enabled=false) on conflict do no nothing is slow?

From: Ivan Petrov <capacytron(at)gmail(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: why insert into UNLOGGED table WITH (autovacuum_enabled=false) on conflict do no nothing is slow?
Date: 2021-04-04 21:34:12
Message-ID: CAEARqsECRW4dBS8p91p3CC3bH2MLSbrVsn=hJR_2_GJEN9zuQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi, I'have rather odd case.
I have a "cache" table in Postgres and I need to insert 100K - 1M records
in parallel from different sources. Sources can try to insert duplicated
data.
I'm too lazy to write complex sync code around INSERT process that is why I
do it this way:
1. create UNLOGGED table WITH (autovacuum_enabled=false)
2. do insert into TABLE (foo,bar) values (1,2) on conflict do nothing.

I'm fine with lower perf compared to the COPY command since writing
synchronization is 100 time more expensive than slow insert.
BUT the performance is waaay to slow.
It takes around 10.000 ms to insert 50.000 rows.
Each row has 150 columns.
Table has single PK (I can't drop it)

Why is it so slow?
Can I do something with it?

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ivan Petrov 2021-04-05 10:19:42 Re: why insert into UNLOGGED table WITH (autovacuum_enabled=false) on conflict do no nothing is slow?
Previous Message Raul Garcia 2021-04-04 01:53:04 test