Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 846DB2E0032 for ; Mon, 28 Apr 2008 14:53:24 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 06768-06 for ; Mon, 28 Apr 2008 14:53:18 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by developer.postgresql.org (Postfix) with ESMTP id A6D4E2E002D for ; Mon, 28 Apr 2008 14:53:20 -0300 (ADT) thread-index: AcipWNb98tCu7W5YQjug5eBkaKu3rw== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Received: from [192.168.1.33] ([82.2.86.105]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 28 Apr 2008 13:53:59 -0400 Message-ID: <48160F05.2090207@enterprisedb.com> Date: Mon, 28 Apr 2008 18:53:09 +0100 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: "John Rouillard" Cc: Subject: Re: Very poor performance loading 100M of sql data using copy References: <20080428172431.GI6622@renesys.com> In-Reply-To: <20080428172431.GI6622@renesys.com> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 28 Apr 2008 17:54:00.0875 (UTC) FILETIME=[D6F66FB0:01C8A958] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/407 X-Sequence-Number: 29900 John Rouillard wrote: > We are running postgresql-8.1.3 under Centos 4 You should upgrade, at least to the latest minor release of the 8.1 series (8.1.11), as there has been a bunch of important bug and security fixes. Or even better, upgrade to 8.3, which has reduced the storage size of especially variable length datatypes like text/char/varchar in particular. As your COPY is I/O bound, reducing storage size will translate directly to improved performance. > dm-6 is where the data files reside and dm-4 is where the WAL archives > are kept. Note all the DM's are on the same RAID 0 device /dev/sda2. Another reason to upgrade to 8.3: if you CREATE or TRUNCATE the table in the same transaction as you COPY into it, you can avoid WAL logging of the loaded data, which will in the best case double your performance as your WAL is on the same physical drives as the data files. > The only indexes we have to drop are the ones on the primary keys > (there is one non-primary key index in the database as well). > > Can you drop an index on the primary key for a table and add it back > later? Am I correct in saying: the primary key index is what enforces > the unique constraint in the table? If the index is dropped and > non-unique primary key data has been added, what happens when you > re-add the index? Yes, the index is what enforces the uniqueness. You can drop the primary key constraint, and add it back after the load with ALTER TABLE. If the load introduces any non-unique primary keys, adding the primary key constraint will give you an error and fail. Dropping and recreating the indexes is certainly worth trying. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com