Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 80C09B5DBC8 for ; Thu, 3 Nov 2011 13:06:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 00602-06 for ; Thu, 3 Nov 2011 16:06:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id A5154B5DBBD for ; Thu, 3 Nov 2011 13:06:08 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Thu, 03 Nov 2011 11:06:07 -0500 Message-Id: <4EB27596020000250004298C@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Thu, 03 Nov 2011 11:05:58 -0500 From: "Kevin Grittner" To: "siva palanisamy" , Cc: "Siva Palanisamy" Subject: Re: Optimization required for multiple insertions in PostgreSQL References: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/54 X-Sequence-Number: 45565 siva palanisamy wrote: > I basically have 3 tables. One being the core table and the other > 2 depend on the 1st. I have the requirement to add upto 70000 > records in the tables. I do have constraints (primary & foreign > keys, index, unique etc) set for the tables. I can't go for bulk > import (using COPY command) as there is no standard .csv file in > requirement, and the mapping is explicitly required plus few > validations are externally applied in a C based programming file. > Each record details (upto 70000) will be passed from .pgc (an ECPG > based C Programming file) to postgresql file. It takes less time > for the 1st few records and the performance is turning bad to the > latter records! The result is very sad that it takes days to cover > upto 20000! What are the performance measures could I step in into > this? Please guide me There's an awful lot you're not telling us, like what version of PostgreSQL you're using, what your hardware looks like, how many rows you're trying to insert per database transaction, what resource looks like on the machine when it's running slow, what the specific slow queries are and what their execution plans look like, etc. I could make a lot of guesses and take a shot in the dark with some generic advice, but you would be better served by the more specific advice you will get if you provide more detail. Please review this page (and its links) and post again: http://wiki.postgresql.org/wiki/SlowQueryQuestions -Kevin