X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9EE2A9DD6EA for ; Thu, 1 Dec 2005 22:27:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21524-06 for ; Thu, 1 Dec 2005 22:26:54 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) by postgresql.org (Postfix) with ESMTP id A9F419DD6EF for ; Thu, 1 Dec 2005 22:26:55 -0400 (AST) Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 Corporation www.Mi8.com (D2)); Thu, 01 Dec 2005 21:26:51 -0500 X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 1 Dec 2005 21:26:43 -0500 Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Fri, 2 Dec 2005 02:26:43 +0000 User-Agent: Microsoft-Entourage/11.2.1.051004 Date: Thu, 01 Dec 2005 18:26:42 -0800 Subject: Re: COPY into table too slow with index: now an I/O From: "Luke Lonergan" To: "Rick Schumeyer" , pgsql-performance@postgresql.org Message-ID: Thread-Topic: [PERFORM] COPY into table too slow with index: now an I/O question Thread-Index: AcX2xgRQYOdxLI0BQiKG1sSBUd6zLAAIdCbq In-Reply-To: <00df01c5f6c5$2e84c310$0200a8c0@dell8200> MIME-Version: 1.0 X-OriginalArrivalTime: 02 Dec 2005 02:26:43.0950 (UTC) FILETIME=[D614E8E0:01C5F6E7] X-WSS-ID: 6F916F614J84424997-03-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.253 required=5 tests=[RCVD_NUMERIC_HELO=1.253] X-Spam-Score: 1.253 X-Spam-Level: * X-Archive-Number: 200512/46 X-Sequence-Number: 15867 Rick, On 12/1/05 2:18 PM, "Rick Schumeyer" wrote: > As a follow up to my own question: > =20 > I reran the COPY both ways (with the index and without) while running ios= tat. > The following values > are averages: > %user %nice %sys %iowait %idle > no index 39 0 2.8 11 47 > index 16 1.5 2.1 34 46 > =20 > I=B9m no performance guru, so please indulge a couple of silly questions: > =20 > 1) Why is there so much idle time? I would think the CPU would eith= er be > busy or waiting for IO. The 100% represents 2 CPUs. When one CPU is fully busy you should see 50% idle time. > 2) It seems that I need to improve my disk situation. Would it help= to > add another drive to my PC and > keep the input data on a separate drive from my pg tables? If so, some > pointers on the best way to set that up > would be appreciated. Putting the index and the table on separate disks will fix this IMO. I think you can do that using the "TABLESPACE" concept for each. The problem I see is nicely shown by the increase in IOWAIT between the two patterns (with and without index). It seems likely that the pattern is: A - insert a tuple into the table B - insert an entry into the index C - fsync the WAL - repeat This can be as bad as having a disk seek to access the table data every tim= e the 8KB page boundary is crossed, then again for the index, then again for the WAL, and random disk seeks happen only as fast as about 10ms, so you ca= n only do those at a rate of 100/s. > Please let me know if anyone has additional ideas. This is a fairly common problem, some people drop the index, load the data, then recreate the index to get around it. - Luke