*really* bad insert performance on table with unique index - Mailing list pgsql-performance

From Jon Nelson
Subject *really* bad insert performance on table with unique index
Date
Msg-id CAKuK5J3VjrXJGW+noBo=fk8vBX5tFVpbnb7oKsdPpucOxUq6LA@mail.gmail.com
Whole thread Raw
Responses Re: *really* bad insert performance on table with unique index  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-performance
I created a table with two columns: an id SERIAL (primary key) and a
text (not null), and then added a unique index on the text field.
Then I ran the following query (with a huge work_mem - 20GB):

insert into tableA (text_field) select distinct other_text_field from
some_huge_set_of_tables

After 36 hours it had only written 3 GB (determined by looking at what
files it was writing to).
I started over with a TRUNCATE, and then removed the index and tried again.
This time it took 3807270.780 ms (a bit over an hour).
Total number of records: approx 227 million, comprising 16GB of storage.

Why the huge discrepancy?

--
Jon

pgsql-performance by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: From Simple to Complex
Next
From: Alessandro Gagliardi
Date:
Subject: Re: From Simple to Complex