pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Divakar Singh <dpsmails@yahoo.com>
To: pgsql-performance@postgresql.org
Subject: Insert performance with composite index
Date: Mon, 1 Nov 2010 05:49:14 -0700 (PDT)
Message-ID: <293254.80548.qm@web65413.mail.ac4.yahoo.com> (raw)

Hi,
I am trying to tune my libpq program for insert performance.
When I tried inserting 1M rows into a table with a Primary Key, it took almost 
62 seconds.
After adding a composite index of 2 columns, the performance degrades to 125 
seconds.
I am using COPY to insert all data in 1 transaction.

the table definition is 

CREATE TABLE ABC
(
  event integer,
  innodeid character varying(80),
  innodename character varying(80),
  sourceid character varying(300),
  intime timestamp(3) without time zone,
  outnodeid character varying(80),
  outnodename character varying(80),
  destinationid character varying(300),
  outtime timestamp(3) without time zone,
  bytes integer,
  cdrs integer,
  tableindex integer NOT NULL,
  noofsubfilesinfile integer,
  recordsequenceintegerlist character varying(1000),
  CONSTRAINT tableindex_pkey PRIMARY KEY (tableindex)
)

the index definition is 


CREATE INDEX "PK_AT2"
  ON ABC
  USING btree
  (event, tableindex)
TABLESPACE sample;

Any tip to increase the insert performance in this case?

It would also be helpful if someone can send comprehensive libpq programming 
guide for PG 9.x. Online doc of libpq is not much helpful for a newbie like me.


 Best Regards,
Divakar



      

view thread (16+ messages)  latest in thread

Message-ID: <293254.80548.qm@web65413.mail.ac4.yahoo.com>
Permalink:  ../293254.80548.qm@web65413.mail.ac4.yahoo.com/
Also on:    postgresql.org/message-id/293254.80548.qm@web65413.mail.ac4.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dpsmails@yahoo.com
  Subject: Re: Insert performance with composite index
  In-Reply-To: <293254.80548.qm@web65413.mail.ac4.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox