Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 525B9B5DBD8 for ; Mon, 27 Jun 2011 16:46:23 -0300 (ADT) 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 09867-02-3 for ; Mon, 27 Jun 2011 19:46:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gransy.com (mail.gransy.com [82.208.29.194]) by mail.postgresql.org (Postfix) with ESMTP id 81F92B5DBDF for ; Mon, 27 Jun 2011 16:46:14 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.gransy.com (Postfix) with ESMTP id 695D24A2214; Mon, 27 Jun 2011 21:46:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at nathalia.gransy.com Received: from mail.gransy.com ([127.0.0.1]) by localhost (Nathalka.gransy.com.gransy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cjBiZ8FLIcAS; Mon, 27 Jun 2011 21:46:12 +0200 (CEST) Received: from [192.168.1.221] (ip-78-45-133-255.net.upcbroadband.cz [78.45.133.255]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id 7785B4A21D7; Mon, 27 Jun 2011 21:46:12 +0200 (CEST) Message-ID: <4E08DE04.8050605@fuzzy.cz> Date: Mon, 27 Jun 2011 21:46:12 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110619 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Jenish CC: Kevin Grittner , pgsql-performance@postgresql.org Subject: Re: Performance issue with Insert References: <4E084F71020000250003EC59@gw.wicourts.gov> <7d7f310e31bbaa62793e13897d889e1d.squirrel@sq.gransy.com> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/251 X-Sequence-Number: 44184 Dne 27.6.2011 17:58, Jenish napsal(a): > > Hi, > > I have already checked all the statements present in the trigger, no one > is taking more then 20 ms. > > I am using 8-Processor, Quad-Core Server ,CPU utilization is more then > 90-95 % for all. (htop result) So all cores are 95% utilized? That means you're CPU bound and you need to fix that somehow. How much of that belongs to postgres? Are there other processes consuming significant portion of CPU? And what do you mean by 'utilized'? Does that mean user/sys time, or wait time? > DB has 960 concurrent users. Whad does that mean? Does that mean there are 960 active connections? > io : writing 3-4 MB per second or less (iotop result). Sequential or random? Post a few lines of 'iostat -x 1' and a few lines of 'vmstat 1' (collected when the database is busy). > Scenario : All insert are waiting for previous insert to complete. Cant > we avoid this situation ? What do you mean by 'previous'? Does that mean another insert in the same session (connection), or something performed in another session? > What is the "max_connections" postgresql support? That limits number of background processes - each connection is served by a dedicated posgres process. You can see that in top / ps output. High values usually mean you need some kind of pooling (you probably already have one as you're using application server). And if the connections are really active (doing something all the time), this should not be significantly higher than the number of cores. See, you have 8 cores, which means 8 seconds of CPU time each second. No matter how many connections you allow, you still have just those 8 seconds. So if you need to perform 100x something that takes 1 second, you need to spend 100 seconds of CPU time. So with those 8 cores, you can do that in about 12,5 seconds. Actually if you create too many connections, you'll notice it takes much more - there's an overhead with process management, context switching, locking etc. regards Tomas