Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id EBF142E383B for ; Tue, 5 Feb 2008 16:55:42 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 11267-05 for ; Tue, 5 Feb 2008 16:55:33 -0400 (AST) Received: from brmea-mail-2.sun.com (brmea-mail-2.Sun.COM [192.18.98.43]) by postgresql.org (Postfix) with ESMTP id 49C932E3278 for ; Tue, 5 Feb 2008 16:55:35 -0400 (AST) Received: from fe-amer-10.sun.com ([192.18.109.80]) by brmea-mail-2.sun.com (8.13.6+Sun/8.12.9) with ESMTP id m15KtXxh010514 for ; Tue, 5 Feb 2008 20:55:33 GMT Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JVS00L016XZEF00@mail-amer.sun.com> (original mail from J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; Tue, 05 Feb 2008 13:55:33 -0700 (MST) Received: from [129.148.168.2] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JVS004T6A2HVX80@mail-amer.sun.com>; Tue, 05 Feb 2008 13:54:18 -0700 (MST) Date: Tue, 05 Feb 2008 15:50:35 -0500 From: "Jignesh K. Shah" Subject: Re: Benchmark Data requested In-reply-to: <47A8C1B9.10200@enterprisedb.com> To: Heikki Linnakangas Cc: Dimitri Fontaine , pgsql-performance@postgresql.org, Simon Riggs , Greg Smith Message-id: <47A8CC1B.1050000@sun.com> Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 8BIT References: <1202150236.4252.521.camel@ebony.site> <200802051506.51581.dfontaine@hi-media.com> <1202221496.4252.680.camel@ebony.site> <200802051815.25800.dfontaine@hi-media.com> <47A8C1B9.10200@enterprisedb.com> User-Agent: Thunderbird 2.0.0.4 (X11/20070622) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/53 X-Sequence-Number: 28595 Hi Heikki, Is there a way such an operation can be spawned as a worker process? Generally during such loading - which most people will do during "offpeak" hours I expect additional CPU resources available. By delegating such additional work to worker processes, we should be able to capitalize on additional cores in the system. Even if it is a single core, the mere fact that the loading process will eventually wait for a read from the input file which cannot be non-blocking, the OS can timeslice it well for the second process to use those wait times for the index population work. What do you think? Regards, Jignesh Heikki Linnakangas wrote: > Dimitri Fontaine wrote: >> Le mardi 05 février 2008, Simon Riggs a écrit : >>> I'll look at COPY FROM internals to make this faster. I'm looking at >>> this now to refresh my memory; I already had some plans on the shelf. >> >> Maybe stealing some ideas from pg_bulkload could somewhat help here? >> >> http://pgfoundry.org/docman/view.php/1000261/456/20060709_pg_bulkload.pdf >> >> >> IIRC it's mainly about how to optimize index updating while loading >> data, and I've heard complaints on the line "this external tool has >> to know too much about PostgreSQL internals to be trustworthy as >> non-core code"... so... > > I've been thinking of looking into that as well. The basic trick > pg_bulkload is using is to populate the index as the data is being > loaded. There's no fundamental reason why we couldn't do that > internally in COPY. Triggers or constraints that access the table > being loaded would make it impossible, but we should be able to detect > that and fall back to what we have now. > > What I'm basically thinking about is to modify the indexam API of > building a new index, so that COPY would feed the tuples to the > indexam, instead of the indexam opening and scanning the heap. The > b-tree indexam would spool the tuples into a tuplesort as the COPY > progresses, and build the index from that at the end as usual. >