Skip to main content
Bumped by Community user
added [postgresql-performance] to 571 questions - Shog9 (Id=1924)
Link
Bumped by Community user
added 72 characters in body
Source Link

EDIT3:

There are no foreign keys and no triggers on the tables.

EDIT3:

There are no foreign keys and no triggers on the tables.

added 2239 characters in body; edited title
Source Link

Postgresql 11 - slow insert performance when table reaches ~5 million records

EDIT:EDIT:

Tried to REINDEX all to see if would be a filled index issue - no results.

EDIT2:

The tables:

create table customer (
    field1  serial      not null,
    field2  uuid        not null default (uuid_generate_v1()),
    field3  varchar(11) null,
    field4  varchar(2)  not null,
    field5  varchar(1)  not null,
    field6  varchar(40) not null,
    field7  varchar(40) null,
    field8  varchar(40),
    field9  bigint,
    field10 varchar(15),
    field11 varchar(20),
    field12 integer,
    field13 date,
    field14 varchar(1),
    field15 integer,
    field16 varchar(100),
    field17 varchar(100),
    field18 boolean,
    field19 integer,
    field20 varchar(20),
    field21 timestamp,
    field22 timestamp,
    field23 varchar(2),
    field24 varchar(40) not null,
    field25 varchar(40),
    field26 boolean,
    field27 boolean     null
) partition by hash (
    field1
);

-- Fillfactor = 85 because this table is a copy from the original so it might
-- eventually get unordered data
alter table customer
    add constraint customer_pk
        primary key (field1) with (fillfactor = 85);

-- CREATE 10 PARTITIONS...

create index idx_customer_01 on customer (field2) with (fillfactor =75);
create index idx_customer_02 on customer (field9, field14) with (fillfactor =75);
create index idx_customer_03 on customer (field25, field14) with (fillfactor =75);

create table customer_contacts (
    field1 serial,
    field2 uuid default (uuid_generate_v1()),
    field3 uuid    not null,
    field4 integer not null,
    field5 smallint,
    field6 bigint,
    field7 boolean not null
) partition by hash (
    field1
);

alter table customer_contacts
    add constraint customer_contacts_pk
        primary key (field1) with (fillfactor =85);

-- CREATE 10 PARTITIONS...

create index idx_customer_contacts_01 on customer_contacts (field2) with (fillfactor =85);
create index idx_customer_contacts_02 on  customer_contacts (field3, field4) with (fillfactor =85);

Postgresql 11 - slow insert performance

EDIT:

Tried to REINDEX all to see if would be a filled index issue - no results.

Postgresql 11 - slow insert performance when table reaches ~5 million records

EDIT:

Tried to REINDEX all to see if would be a filled index issue - no results.

EDIT2:

The tables:

create table customer (
    field1  serial      not null,
    field2  uuid        not null default (uuid_generate_v1()),
    field3  varchar(11) null,
    field4  varchar(2)  not null,
    field5  varchar(1)  not null,
    field6  varchar(40) not null,
    field7  varchar(40) null,
    field8  varchar(40),
    field9  bigint,
    field10 varchar(15),
    field11 varchar(20),
    field12 integer,
    field13 date,
    field14 varchar(1),
    field15 integer,
    field16 varchar(100),
    field17 varchar(100),
    field18 boolean,
    field19 integer,
    field20 varchar(20),
    field21 timestamp,
    field22 timestamp,
    field23 varchar(2),
    field24 varchar(40) not null,
    field25 varchar(40),
    field26 boolean,
    field27 boolean     null
) partition by hash (
    field1
);

-- Fillfactor = 85 because this table is a copy from the original so it might
-- eventually get unordered data
alter table customer
    add constraint customer_pk
        primary key (field1) with (fillfactor = 85);

-- CREATE 10 PARTITIONS...

create index idx_customer_01 on customer (field2) with (fillfactor =75);
create index idx_customer_02 on customer (field9, field14) with (fillfactor =75);
create index idx_customer_03 on customer (field25, field14) with (fillfactor =75);

create table customer_contacts (
    field1 serial,
    field2 uuid default (uuid_generate_v1()),
    field3 uuid    not null,
    field4 integer not null,
    field5 smallint,
    field6 bigint,
    field7 boolean not null
) partition by hash (
    field1
);

alter table customer_contacts
    add constraint customer_contacts_pk
        primary key (field1) with (fillfactor =85);

-- CREATE 10 PARTITIONS...

create index idx_customer_contacts_01 on customer_contacts (field2) with (fillfactor =85);
create index idx_customer_contacts_02 on  customer_contacts (field3, field4) with (fillfactor =85);
added 851 characters in body
Source Link
Loading
added 653 characters in body
Source Link
Loading
Source Link
Loading