Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 61FAE650156 for ; Sun, 31 Aug 2008 22:49:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50508-02 for ; Sun, 31 Aug 2008 22:49:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by postgresql.org (Postfix) with ESMTP id E12FF64FD63 for ; Sun, 31 Aug 2008 22:49:41 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 9C23F5C03E; Mon, 1 Sep 2008 09:49:35 +0800 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 8047B1E0435; Mon, 1 Sep 2008 09:49:35 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KYLxrDU1GNqV; Mon, 1 Sep 2008 09:49:34 +0800 (WST) Received: from [192.168.44.89] (203-59-94-220.perm.iinet.net.au [203.59.94.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id 9CDD91E0434; Mon, 1 Sep 2008 09:49:34 +0800 (WST) Message-ID: <48BB4A2D.9080404@postnewspapers.com.au> Date: Mon, 01 Sep 2008 09:49:33 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Thomas Finneid Cc: pgsql-performance@postgresql.org Subject: Re: slow update of index during insert/copy References: <48BA9D65.2020001@ifi.uio.no> In-Reply-To: <48BA9D65.2020001@ifi.uio.no> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/432 X-Sequence-Number: 31313 Thomas Finneid wrote: > Hi > > I am working on a table which stores up to 125K rows per second and I > find that the inserts are a little bit slow. The insert is in reality a > COPY of a chunk of rows, up to 125K. A COPY og 25K rows, without an > index, is fast enough, about 150ms. With the index, the insert takes > about 500ms. The read though, is lightning fast, because of the index. > It takes only 10ms to retrieve 1000 rows from a 15M row table. As the > table grows to several billion rows, that might change though. > > I would like the insert, with an index, to be a lot faster than 500ms, > preferrably closer to 150ms. Any advice on what to do? > Additionally, I dont enough about pg configuring to be sure I have > included all the important directives and given them proportional > values, so any help on that as well would be appreciated. > > Here are the details: > > postgres 8.2.7 on latest kubuntu, running on dual Opteron quad cores, > with 8GB memory and 8 sata disks on a raid controller (no raid config) Just on a side note, your system is pretty strangely heavy on CPU compared to its RAM and disk configuration. Unless your workload in Pg is computationally intensive or you have something else hosted on the same machine, those CPUs will probably sit mostly idle. The first thing you need to do is determine where, during your bulk loads, the system is bottlenecked. I'd guess it's stuck waiting for disk writes, personally, but I'd want to investigate anyway. If you're not satisfied with the results from pg_bulkload you can look into doing things like moving your indexes to separate tablespaces (so they don't fight for I/O on the same disk sets as your tables), separating your bulk load tables from other online/transactional tables, etc. Also, to relay common advice from this list: If you land up considering hardware as a performance answer, getting a decent SAS RAID controller with a battery backed cache (so you can enable its write cache) and a set of fast SAS disks might be worth it. For that matter, a good SATA RAID controller and some 10kRPM SATA disks could help too. It all appears to depend a lot on the particular workload and the characteristics of the controller, though. -- Craig Ringer