Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 170ED1337B2F for ; Mon, 1 Nov 2010 09:49:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 79116-01 for ; Mon, 1 Nov 2010 12:49:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm16.bullet.mail.ac4.yahoo.com (nm16.bullet.mail.ac4.yahoo.com [98.139.52.213]) by mail.postgresql.org (Postfix) with SMTP id 5F70D1337990 for ; Mon, 1 Nov 2010 09:49:15 -0300 (ADT) Received: from [98.139.52.197] by nm16.bullet.mail.ac4.yahoo.com with NNFMP; 01 Nov 2010 12:49:14 -0000 Received: from [98.139.52.168] by tm10.bullet.mail.ac4.yahoo.com with NNFMP; 01 Nov 2010 12:49:14 -0000 Received: from [127.0.0.1] by omp1051.mail.ac4.yahoo.com with NNFMP; 01 Nov 2010 12:49:14 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 503882.22947.bm@omp1051.mail.ac4.yahoo.com Received: (qmail 94827 invoked by uid 60001); 1 Nov 2010 12:49:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1288615754; bh=k3TaP6dWnX3rwdHcf/lNiGc/j2PMDI1aNaph68pMSAg=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=QJ1VaySTDAbBLAssr/n06Mm35THH3aME9BY3K0buBeTq3hbwLw364zhqUxRnt0d3VzEsUFrf5WjFrpfNKsKsvHFpTwUGxJF2vNaRuHWBNeGQvx4vsfeK0g1ZT+hzbwLndoFebhLE5fGEVgeWimyyIAezIdou1sKmmd+AVkZn0to= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=vfs7uGqIP3T0rc6WI01NP3+BZ6og8sAR9aN4sf4FP9q2VOqyUzBA3EqXat8ZXb19+vn01HRi5HTwZGQEi4D0oRVbuqC/cGGVAXR5z5EtuaDHQsZnZCSn5sanF/enAQY8qol5P9OSW684p3rpdtEm9e2V1LaMBi56vXOJDiRcW7Q=; Message-ID: <293254.80548.qm@web65413.mail.ac4.yahoo.com> X-YMail-OSG: s0EIQPQVM1ns7OOmyG9vDoghxEzv6tH9LmbeVkBiGZCBstk eztvlashRk2URvAYBPIQ1NOFKJK7.UIEv3W7PVu2fEXyi2zTqRLVp9zcL6fW rGSE5c0T5NaFHjkA2W0gcrpJmUsaic6mcCO4w2etGD0y2KEBJWqOzbecUXSS PpxyNxk4KAILSZl1vH1kjQhTA_wcu0Wh_A_HEQIPOn33Dvt3XdDXuVijACdu 1dmAzWXjdgK9tB4OUZgoY0nt9ZcqH8bzBUROa_NA3p2bdPlLMyEllCWGu9Si gckuIP9hjOuOK_tOnacnL8CQpkCSnjKVQrXHp7Li7lCoxN2XHz7dJGYQ- Received: from [194.237.142.17] by web65413.mail.ac4.yahoo.com via HTTP; Mon, 01 Nov 2010 05:49:14 PDT X-Mailer: YahooMailRC/504.5 YahooMailWebService/0.8.107.284920 Date: Mon, 1 Nov 2010 05:49:14 -0700 (PDT) From: Divakar Singh Subject: Insert performance with composite index To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-189303600-1288615754=:80548" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/2 X-Sequence-Number: 41026 --0-189303600-1288615754=:80548 Content-Type: text/plain; charset=us-ascii 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 --0-189303600-1288615754=:80548 Content-Type: text/html; charset=us-ascii
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


--0-189303600-1288615754=:80548--