Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0AD221336971 for ; Thu, 4 Nov 2010 18:02:59 -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 92053-07 for ; Thu, 4 Nov 2010 21:02:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mh3.mail.rice.edu (mh3.mail.rice.edu [128.42.199.10]) by mail.postgresql.org (Postfix) with ESMTP id C09321335B36 for ; Thu, 4 Nov 2010 18:02:51 -0300 (ADT) Received: from mh3.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh3.mail.rice.edu (Postfix) with ESMTP id 5E67D28F6E0; Thu, 4 Nov 2010 16:02:51 -0500 (CDT) X-Virus-Scanned: by amavis-2.6.4 at mh3.mail.rice.edu, auth channel Received: from mh3.mail.rice.edu ([127.0.0.1]) by mh3.mail.rice.edu (mh3.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id n0EQ5OjlQfkh; Thu, 4 Nov 2010 16:02:51 -0500 (CDT) X-SMTP-Auth: no X-SMTP-Auth: no Received: from aart.is.rice.edu (aart.is.rice.edu [168.7.56.48]) by mh3.mail.rice.edu (Postfix) with ESMTP id 192B528F6E3; Thu, 4 Nov 2010 16:02:51 -0500 (CDT) Received: by aart.is.rice.edu (Postfix, from userid 18612) id C30252D5A6; Thu, 4 Nov 2010 16:02:50 -0500 (CDT) Date: Thu, 4 Nov 2010 16:02:50 -0500 From: Kenneth Marshall To: Jonathan Hoover Cc: "pgsql-admin@postgresql.org" Subject: Re: Disk Performance Problem on Large DB Message-ID: <20101104210250.GL27429@aart.is.rice.edu> References: <68C107706843A54BA7D9CAEF123ADF05010346C85A@SP2-EX07VS03.ds.corp.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68C107706843A54BA7D9CAEF123ADF05010346C85A@SP2-EX07VS03.ds.corp.yahoo.com> User-Agent: Mutt/1.5.16 (2007-06-09) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/32 X-Sequence-Number: 35998 On Thu, Nov 04, 2010 at 01:42:49PM -0700, Jonathan Hoover wrote: > Hello, > > I have a RHEL 5 box, 4 GB RAM, single hard drive SATA, Intel Core 2 Duo 2.4. A basic workstation. > > I have a simple database, with one table for now. It has 4 columns: > > anid serial primary key unique, > time timestamp, > source varchar(5), > unitid varchar(15), > guid varchar(32) > > There is a btree index on each. > > I am loading data 1,000,000 (1M) rows at a time using psql and a COPY command. Once I hit 2M rows, my performance just drops out, and the next 1M never finishes. It takes 7 minutes for 1M rows to load. Once 2M are in there, I've waited an hour, and nothing. It doesn't seem to matter which 1M rows I try to load next, none ever finish. Each 1M rows is about 70MB on disk in the raw input file. > > I have "atop" installed, and it reports the drives at 100%, which it reports for the first 1M rows too. The MBw/s goes from 20+ on the first 2M rows, down to about 4 MBw/s or less now. The processor usage is at about 2 to 8% at this time (used by postgres). > > I have even waited for 1M rows to load, then done a vacuum for no good reason, then even restarted postgresql. I've made sure no disk or proc activity is happening before I start the next 1M rows. None of that seems to matter. > > I have a total of about 70M rows to load, but am at a standstill. I've read up on whatever performance docs I can find online, but I am not getting anywhere. > > I've increased shared_buffers to 256MB, and I've tried it with fsync commented out as per the default config. I've also tried it with fsync=off. No difference. > > Ideas? Thanks in advance, > Jon The initial 1M load if the table has just been truncated or created has no WAL logging. You can boost maintenance_work_mem to increase index creation/update performance. You are severely I/O limited and would be better off dropping your indexes during the load and re- creating them afterwards. If you are starting with an empty table, truncate it and then load all the data in a single transaction, all 7 COPY commands. Then COMMIT and build the indexes. Your question is also missing key information like config details, PostgreSQL version, ... Cheers, Ken