Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0E2331337B39 for ; Mon, 13 Dec 2010 07:11:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 96208-05 for ; Mon, 13 Dec 2010 11:11:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id B35631336971 for ; Mon, 13 Dec 2010 07:11:00 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id D1B5514A6; Mon, 13 Dec 2010 06:10:59 -0500 (EST) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mmT-PG07Sl2w; Mon, 13 Dec 2010 06:10:47 -0500 (EST) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id A0FBA2D; Mon, 13 Dec 2010 06:10:46 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id ECF3EAF240; Mon, 13 Dec 2010 19:10:44 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1gKaoli0mtkd; Mon, 13 Dec 2010 19:10:39 +0800 (WST) Received: from [10.1.1.5] (58-7-229-181.dyn.iinet.net.au [58.7.229.181]) (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 ESMTPSA id EE295AE567; Mon, 13 Dec 2010 19:10:38 +0800 (WST) Message-ID: <4D05FF2D.4030505@postnewspapers.com.au> Date: Mon, 13 Dec 2010 19:10:37 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc14 Thunderbird/3.1.4 MIME-Version: 1.0 To: Royce Ausburn CC: pgsql-performance@postgresql.org Subject: Re: CPU bound References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/161 X-Sequence-Number: 41613 On 12/13/2010 10:43 AM, Royce Ausburn wrote: > Hi all, > > I notice that when restoring a DB on a laptop with an SDD, typically postgres is maxing out a CPU - even during a COPY. I wonder, what is postgres usually doing with the CPU? I would have thought the disk would usually be the bottleneck in the DB, but occasionally it's not. We're embarking on a new DB server project and it'd be helpful to understand where the CPU is likely to be the bottleneck. A few thoughts: - Pg isn't capable of using more than one core for a single task, so if you have one really big job, you'll more easily start struggling on CPU. Restores appear to be a pain point here, though recent work has been done to address that. - Even with pg_dump/pg_restore's parallel restore, you can't be using more than one core to do work for a single COPY or other individual operation. You can only parallelize down to the table level at the moment. - Pg's design has always focused on rotating media. It can make sense to trade increased CPU costs for reduced I/O when disk storage is slower relative to CPU/RAM. There aren't, AFAIK, many controls beyond the random/seq io knobs to get Pg to try to save CPU at the cost of more I/O when opportunities to do so appear. - Pg's CPU load depends a lot on the data types and table structures in use. What're your tables like? Do they have indexes added at the end, or are they created with indexes then populated with rows? The former is MUCH faster. Are they full of NUMERIC fields? Those seem to be incredibly slow compared to int/float/etc, which is hardly surprising given their storage and how they work. -- Craig Ringer