X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 6EC119DCA20 for ; Mon, 20 Mar 2006 04:35:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06325-02 for ; Mon, 20 Mar 2006 04:35:22 -0400 (AST) X-Greylist: delayed 00:20:41.623365 by SQLgrey- Received: from mail.mnc.ch (62-2-77-205.business.cablecom.ch [62.2.77.205]) by postgresql.org (Postfix) with ESMTP id E92DF9DC812 for ; Mon, 20 Mar 2006 04:35:18 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.mnc.ch (Postfix) with ESMTP id A448EA82C6; Mon, 20 Mar 2006 09:35:29 +0100 (CET) Received: from mail.mnc.ch ([127.0.0.1]) by localhost (mail.test.lan [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 17629-10; Mon, 20 Mar 2006 09:35:28 +0100 (CET) Received: from meuh.mnc.lan (62-2-77-204.business.cablecom.ch [62.2.77.204]) by mail.mnc.ch (Postfix) with ESMTP id 1F44FA82BD; Mon, 20 Mar 2006 09:35:28 +0100 (CET) Received: by meuh.mnc.lan (Postfix, from userid 1000) id B71EA1837A5; Mon, 20 Mar 2006 09:35:14 +0100 (CET) To: Mark Kirkwood Cc: pgsql-performance@postgresql.org Subject: Re: planner with index scan cost way off actual cost, advices to tweak cost constants? References: <87ek11gz69.fsf@meuh.mnc.lan> <441CDAAA.20609@paradise.net.nz> X-Hashcash: 1:20:060320:markir@paradise.net.nz::u5GwmW0QvWXTMLe4:000000000000000000000000000000000000000BnIb X-Hashcash: 1:20:060320:pgsql-performance@postgresql.org::xRkc/fRx26gevpKR:000000000000000000000000000000YFv From: Guillaume Cottenceau Date: 20 Mar 2006 09:35:14 +0100 In-Reply-To: <441CDAAA.20609@paradise.net.nz> Message-ID: <87d5ghms3h.fsf@meuh.mnc.lan> Lines: 63 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: amavisd-new at mnc.ch X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.092 required=5 tests=[AWL=0.092] X-Spam-Score: 0.092 X-Spam-Level: X-Archive-Number: 200603/325 X-Sequence-Number: 17762 Hi Mark, Thanks for your reply. > Guillaume Cottenceau wrote: [...] > > Btw, I use postgres 7.4.5 with -B 1000 -N 500 and all > > postgresql.conf default values except timezone = 'UTC', on an > > ext3 partition with data=ordered, and run Linux 2.6.12. > > I didn't see any mention of how much memory is on your server, but > provided you have say 1G, and are using the box solely for a database > server, I would increase both shared_buffers and effective_cache size. This test machine has 1G of (real) memory, servers often have 2G or 4G. The thing is that the application runs on the same machine, and as it is a java application, it takes up a little memory too (we can say half of it should go to java and half to postgres, I guess). Determining the best memory "plan" is not so easy, though your information is priceless and will help a lot! > shared_buffer = 12000 > effective_cache_size = 25000 > > This would mean you are reserving 100M for Postgres to cache relation > pages, and informing the planner that it can expect ~200M available > from the disk buffer cache. To give a better recommendation, we need Ok, thanks. I wanted to investigate this field, but as the application is multithreaded and uses a lot of postgres clients, I wanted to make sure the shared_buffers values is globally for postgres, not just per (TCP) connection to postgres, before increasing the value, fearing to take the whole server down. On a server with 235 connections and -N 512 -B 1024, reading http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html I came up with the following figure: for i in `pidof postmaster`; do pmap -d $i | grep -i writeable ; done | perl -MMDK::Common -ne 'do { push @a, $1; $tot += $1 } if /writeable.private: (\d+)K/; END { print "total postgres private memory: ${tot}K\nmin: " . min(@a) . "K\nmax: " . max(@a) . "K\n"; }' total postgres private memory: 432080K min: 936K max: 4216K As the server has 2G of memory, I was reluctant to increase the amount of shared memory since overall postgres memory use seems already quite high - though 100M more would not kill the server, obviously. Btw, can you comment on the upper figures? > to know more about your server and workload (e.g server memory > configuration and usage plus how close you get to 500 connections). Depending on the server, it can have 200, up to around 400 connections open. As of workload, I am not sure what metrics are suitable. Typically postgres can be seen in the top processes but most queries are quick and average load average reported by the linux kernel is nearly always below 0.3, and often 0.1. These are single or dual xeon 2.8 GHz machines with hardware raid (megaraid or percraid driver) with reasonable performance. -- Guillaume Cottenceau