Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULKFz-0003V7-UM for pgsql-performance@arkaria.postgresql.org; Thu, 28 Mar 2013 21:21:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ULKFz-0008Cq-Ey for pgsql-performance@arkaria.postgresql.org; Thu, 28 Mar 2013 21:21:11 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULKFy-0008Ck-KC for pgsql-performance@postgresql.org; Thu, 28 Mar 2013 21:21:10 +0000 Received: from proofpoint2.mail.rice.edu ([128.42.201.101] helo=pp2.rice.edu) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULKFp-0000cp-I7 for pgsql-performance@postgresql.org; Thu, 28 Mar 2013 21:21:09 +0000 Received: from pps.filterd (pp2.rice.edu [127.0.0.1]) by pp2.rice.edu (8.14.5/8.14.5) with SMTP id r2SJ7FoF001167; Thu, 28 Mar 2013 16:21:00 -0500 Received: from mh10.mail.rice.edu (mh10.mail.rice.edu [128.42.201.30]) by pp2.rice.edu with ESMTP id 1bc36x922x-1; Thu, 28 Mar 2013 16:21:00 -0500 X-Virus-Scanned: by amavis-2.7.0 at mh10.mail.rice.edu, auth channel X-SMTP-Auth: no X-SMTP-Auth: no X-SMTP-Auth: no Received: from aart.rice.edu (aart.rice.edu [168.7.56.48]) by mh10.mail.rice.edu (Postfix) with ESMTP id AD44A6025E; Thu, 28 Mar 2013 16:20:59 -0500 (CDT) Received: by aart.rice.edu (Postfix, from userid 18612) id A359E1006C8; Thu, 28 Mar 2013 16:20:59 -0500 (CDT) Date: Thu, 28 Mar 2013 16:20:59 -0500 From: "ktm@rice.edu" To: Kevin Grittner Cc: kelphet xiong , "pgsql-performance@postgresql.org" Subject: Re: Question about postmaster's CPU usage Message-ID: <20130328212059.GP32580@aart.rice.edu> References: <1364504622.71422.YahooMailNeo@web162902.mail.bf1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1364504622.71422.YahooMailNeo@web162902.mail.bf1.yahoo.com> User-Agent: Mutt/1.5.20 (2009-12-10) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by pp2.rice.edu id r2SJ7FoF001167 X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Thu, Mar 28, 2013 at 02:03:42PM -0700, Kevin Grittner wrote: > kelphet xiong wrote: >=20 > > When I use postgres and issue a simple sequential scan for a > > table inventory using query "select * from inventory;", I can see > > from "top" that postmaster is using 100% CPU, which limits the > > query execution time. My question is that, why CPU is the > > bottleneck here and what is postmaster doing? Is there any way to > > improve the performance? Thanks! >=20 > > explain analyze select * from inventory; > >=20 > > Seq Scan on inventory=A0 (cost=3D0.00..180937.00 rows=3D11745000 width= =3D16) (actual time=3D0.005..1030.403 rows=3D11745000 loops=3D1) > >=A0 Total runtime: 1750.889 ms >=20 > So it is reading and returning 11.7 million rows in about 1 second, > or about 88 nanoseconds (billionths of a second) per row.=A0 You > can't be waiting for a hard drive for many of those reads, or it > would take a lot longer, so the bottleneck is the CPU pushing the > data around in RAM.=A0 I'm not sure why 100% CPU usage would surprise > you.=A0 Are you wondering why the CPU works on the query straight > through until it is done, rather than taking a break periodically > and letting the unfinished work sit there? >=20 > -- > Kevin Grittner > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >=20 Alternatively, purchase a faster CPU if CPU is the bottleneck as it is in this case or partition the work into parallel queuries that can each use a processor. Regards, Ken --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance