X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 30E15D1B1A1 for ; Wed, 4 Aug 2004 10:44:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42070-04 for ; Wed, 4 Aug 2004 13:44:12 +0000 (GMT) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 2C158D1B17B for ; Wed, 4 Aug 2004 10:44:02 -0300 (ADT) Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] helo=bacon.tmsl.demon.co.uk) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1BsM3v-000CNx-0b for pgsql-performance@postgresql.org; Wed, 04 Aug 2004 13:44:11 +0000 Date: Wed, 4 Aug 2004 14:44:08 +0100 From: Paul Thomas To: "pgsql-performance @ postgresql . org" Subject: Re: The black art of postgresql.conf tweaking Message-ID: <20040804144408.A17081@bacon> References: <4110DA83.7020505@clockltd.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: <4110DA83.7020505@clockltd.com>; from paul.serby@clockltd.com on Wed, Aug 04, 2004 at 13:45:55 +0100 X-Mailer: Balsa 1.2.3 Lines: 87 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/51 X-Sequence-Number: 7687 On 04/08/2004 13:45 Paul Serby wrote: > Can anyone give a good reference site/book for getting the most out of > your postgres server. > > All I can find is contradicting theories on how to work out your > settings. > > This is what I followed to setup our db server that serves our web > applications. > > http://www.phpbuilder.com/columns/smith20010821.php3?page=2 > > We have a Dell Poweredge with the following spec. > > CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) > CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) > CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) > CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) > Physical Memory: 2077264 kB > Swap Memory: 2048244 kB > > Apache on the Web server can take up to 300 connections and PHP is > using pg_pconnect > > Postgres is set with the following. > > max_connections = 300 > shared_buffers = 38400 Might be higher that neccessary. Some people reckon that there's no measurable performance going above ~10,000 buffers > sort_mem = 12000 Do you really need 12MB of sort memory? Remember that this is per connection so you could end up with 300x that being allocated in a worst case scenario. > > But Apache is still maxing out the non-super user connection limit. > > The machine is under no load and I would like to up the max_connections > but I would like to know more about what you need to consider before > doing so. I can't think why you should be maxing out when under no load. Maybe you need to investigate this further. > > The only other source I've found is this: > > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > > But following its method my postgres server locks up straight away as it > recommends setting max_connections to 16 for Web sites? I think you've mis-interpreted that. She's talking about using persistent connections - i.e., connection pooling. > > Is there a scientific method for optimizing postgres or is it all > 'finger in the air' and trial and error. Posting more details of the queries which are giving the performance problems will enable people to help you. You're vacuum/analyzing regularly of course ;) People will want to know: - PostgreSQL version - hardware configuration (SCSI or IDE? RAID level?) - table schemas - queries together with EXPLAIN ANALYZE output also output from utils like vmstat, top etc may be of use. HTH -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+