Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B51B59FB304 for ; Tue, 13 Feb 2007 06:08:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 33256-03 for ; Tue, 13 Feb 2007 06:08:16 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.187]) by postgresql.org (Postfix) with ESMTP id 819AB9FB229 for ; Tue, 13 Feb 2007 06:08:15 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so205746nfb for ; Tue, 13 Feb 2007 02:08:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=CB3APXQPvRGbeIy14urSChu2kgC3AuSyiOxfPrcMkS2X9eFYbL6swPMLop29AcIq5nKUfahV6qQTD6FHLHIadQIxaXq0LFsg5PBflsB+VEpOX7FiVh5Qbosg5p0d3vQlZ9fruGg6maG4ZRlYTbwgiuroG0wo7SgRhN3Eum3Z2rY= Received: by 10.49.68.19 with SMTP id v19mr571574nfk.1171361294444; Tue, 13 Feb 2007 02:08:14 -0800 (PST) Received: from ?192.168.1.34? ( [82.3.238.153]) by mx.google.com with ESMTP id x27sm2030854nfb.2007.02.13.02.08.11; Tue, 13 Feb 2007 02:08:12 -0800 (PST) Message-ID: <45D18DF6.9030905@enterprisedb.com> Date: Tue, 13 Feb 2007 10:07:50 +0000 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.8 (X11/20061116) MIME-Version: 1.0 To: ismo.tuononen@solenovo.fi CC: pgsql-performance@postgresql.org Subject: Re: many instances or many databases or many users? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.102 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/123 X-Sequence-Number: 23177 ismo.tuononen@solenovo.fi wrote: > Now we have a server reserved only for postgresql, and I'm wondering if it > is better to set up: > - only one instance and many databases or > - many instances and only one database/instance or > - one instance, one database and many users It depends. One instance should give you best overall throughput, because the OS can maximize the use of resources across all users. There shouldn't be any difference between having one instance with many databases and one database and many users. > server will have 8G memory and 2 processors. > > Earlier we have had problems with difficult queries, some query can take > 100% cpu and all other processes have slowed down. How much data do you have? If it all fits in memory, it's not going to make much difference if you have one or more instances. If not, you might be better off with many instances dividing the memory between them, giving some level of fairness in the memory allocation. Unfortunately there's no way to stop one query from using 100% CPU (though on a 2 CPU server, it's only going to saturate 1 CPU). If you have difficult queries like that, I'd suggest that you take a look at the access plans to check if they could benefit from adding indexes or rewritten in a more efficient way. > is one instance capable to use that 8G of memory? and share it with > different databases/users as needed? > or will one big and difficult query take all memory and slow down whole > server? One instance can use all of the 8G of memory. You should set your shared_buffers to maybe 1-2G. People have different opinions on what exactly is the best value; I'd suggest that you try with different values to see what gives you the best performance in your application. > if there is 2 instances one query can't take all memory, but downside is > that if instance1 is inactive and instance2 is active, there will be much > unused memory (reverved for instance1) and that can produce disk io when > instance2 reads lots of data and sorts it. Yep. > how you have set up your postgresql server? I'd say it's more a question of isolation and administration than performance. For example, do you want to be able to do filesystem-level backups and restores one database at a time? Do you need to shut down one database while keeping the rest of them running? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com