From: Kevin Grittner <kgrittn@ymail.com>
To: kelphet xiong <kelphet@gmail.com>
To: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Question about postmaster's CPU usage
Date: Thu, 28 Mar 2013 14:03:42 -0700 (PDT)
Message-ID: <1364504622.71422.YahooMailNeo@web162902.mail.bf1.yahoo.com> (raw)
In-Reply-To: <CANnt-4YWdFj5R0J6BkrL1UivU5JSn5-E+3PAyAxY1t0zMV_tRw@mail.gmail.com>
References: <CANnt-4YWdFj5R0J6BkrL1UivU5JSn5-E+3PAyAxY1t0zMV_tRw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
kelphet xiong <kelphet@gmail.com> wrote:
> 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!
> explain analyze select * from inventory;
>
> Seq Scan on inventory (cost=0.00..180937.00 rows=11745000 width=16) (actual time=0.005..1030.403 rows=11745000 loops=1)
> Total runtime: 1750.889 ms
So it is reading and returning 11.7 million rows in about 1 second,
or about 88 nanoseconds (billionths of a second) per row. 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. I'm not sure why 100% CPU usage would surprise
you. 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?
--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: kgrittn@ymail.com, kelphet@gmail.com
Subject: Re: Question about postmaster's CPU usage
In-Reply-To: <1364504622.71422.YahooMailNeo@web162902.mail.bf1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox