Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TYM9C-0007uy-Sa for pgsql-performance@postgresql.org; Tue, 13 Nov 2012 19:27:47 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TYM9A-00015x-0L for pgsql-performance@postgresql.org; Tue, 13 Nov 2012 19:27:45 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 87BC328178; Tue, 13 Nov 2012 11:27:42 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 8104A1863D; Tue, 13 Nov 2012 11:27:42 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 7482CC1A53; Tue, 13 Nov 2012 11:27:42 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-2.vmware.com Received: from zcs-prod-ext-mta-2.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-2.vmware.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lcongWEHO9OO; Tue, 13 Nov 2012 11:27:42 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA id B36DDC1A4B; Tue, 13 Nov 2012 11:27:41 -0800 (PST) Message-ID: <50A29F2B.7070604@vmware.com> Date: Tue, 13 Nov 2012 21:27:39 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121027 Icedove/10.0.10 MIME-Version: 1.0 To: Jon Nelson CC: "pgsql-performance@postgresql.org" Subject: Re: postgres 8.4, COPY, and high concurrency References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.1 (-------) X-Archive-Number: 201211/149 X-Sequence-Number: 48515 On 13.11.2012 21:13, Jon Nelson wrote: > I was working on a data warehousing project where a fair number of files > could be COPY'd more or less directly into tables. I have a somewhat nice > machine to work with, and I ran on 75% of the cores I have (75% of 32 is > 24). > > Performance was pretty bad. With 24 processes going, each backend (in COPY) > spent 98% of it's time in semop (as identified by strace). I tried larger > and smaller shared buffers, all sorts of other tweaks, until I tried > reducing the number of concurrent processes from 24 to 4. > > Disk I/O went up (on average) at least 10X and strace reports that the top > system calls are write (61%), recvfrom (25%), and lseek (14%) - pretty > reasonable IMO. > > Given that each COPY is into it's own, newly-made table with no indices or > foreign keys, etc, I would have expected the interaction among the backends > to be minimal, but that doesn't appear to be the case. What is the likely > cause of the semops? I'd guess it's lock contention on WALInsertLock. That means, the system is experiencing lock contention on generating WAL records for the insertions. If that theory is correct, you ought to get a big gain if you have wal_level=minimal, and you create or truncate the table in the same transaction with the COPY. That allows the system to skip WAL-logging the COPY. Or you could upgrade to 9.2. The WAL-logging of bulk COPY was optimized in 9.2, it should help precisely the scenario you're facing. - Heikki