Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 8808E9FA0DD for ; Tue, 28 Aug 2007 10:12:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92026-09 for ; Tue, 28 Aug 2007 10:12:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by postgresql.org (Postfix) with ESMTP id 6C2439F9FF9 for ; Tue, 28 Aug 2007 10:12:21 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Tue, 28 Aug 2007 08:12:19 -0500 Message-Id: <46D3D8D6.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.2 Date: Tue, 28 Aug 2007 08:12:06 -0500 From: "Kevin Grittner" To: "Kevin Kempter" , Subject: Re: server performance issues - suggestions for tuning References: <200708272213.14277.kevin@kevinkempterllc.com> In-Reply-To: <200708272213.14277.kevin@kevinkempterllc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/339 X-Sequence-Number: 26469 >>> On Mon, Aug 27, 2007 at 11:13 PM, in message <200708272213.14277.kevin@kevinkempterllc.com>, Kevin Kempter wrote:=20 > Each night during the nightly batch processing several of the servers (2 = in=20 > particular) slow to a crawl - they are dedicated postgres database = servers.=20 > There is a lot of database activity going on sometimes upwards of 200=20 > concurrent queries =20 > Any thoughts on where to start? =20 Is there any way to queue up these queries and limit how many are running = at a time? I don't know what the experience of others is, but I've found = that when I have more than two to four queries running per CPU, throughput = starts to drop, and response time drops even faster. =20 For purposes of illustration, for a moment let's forget that a query may block waiting for I/O and another query might be able to use the CPU in = the meantime. Then, think of it this way -- if you have one CPU and 100 = queries to run, each of which will take one second, if you start them all and they time slice, nobody gets anything for 100 seconds, so that is your average response time. If you run the one at a time, only one query takes that long, the rest are faster, and you've cut your average response time in half. On top of that, there is overhead to switching between processes, and there can be contention for resources such as locks, which both have a tendency to further slow things down. =20 In the real world, there are multiple resources which can hold up a query, so you get benefit from running more than one query at a time, because they will often be using different resources. =20 But unless that machine has 50 CPUs, you will probably get better = throughput and response time by queuing the requests. =20 -Kevin =20