Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoirY-0007lL-JT for pgsql-performance@arkaria.postgresql.org; Fri, 06 Dec 2013 00:01:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VoirY-0004HQ-3V for pgsql-performance@arkaria.postgresql.org; Fri, 06 Dec 2013 00:01:44 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoirX-0004Gn-68 for pgsql-performance@postgresql.org; Fri, 06 Dec 2013 00:01:43 +0000 Received: from smtp.01.com ([199.36.142.181]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VoirQ-0000iv-Aa for pgsql-performance@postgresql.org; Fri, 06 Dec 2013 00:01:42 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 145663F40D3; Thu, 5 Dec 2013 18:01:36 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GLkwxLAEKtKv; Thu, 5 Dec 2013 18:01:36 -0600 (CST) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id E77113F4112; Thu, 5 Dec 2013 18:01:35 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id D9F543F40F6; Thu, 5 Dec 2013 18:01:35 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NG3TF9LxKpwg; Thu, 5 Dec 2013 18:01:35 -0600 (CST) Received: from [172.47.23.102] (50-1-86-31.dsl.dynamic.sonic.net [50.1.86.31]) by smtp-out-1.01.com (Postfix) with ESMTPSA id 7D9C13F40D3; Thu, 5 Dec 2013 18:01:35 -0600 (CST) Message-ID: <52A113DD.1050809@agliodbs.com> Date: Thu, 05 Dec 2013 16:01:33 -0800 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Max , "pgsql-performance@postgresql.org" Subject: Re: One huge db vs many small dbs References: In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.0 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 12/05/2013 02:42 AM, Max wrote: > Hello, > > We are starting a new project to deploy a solution in cloud with the possibility to be used for 2.000+ clients. Each of this clients will use several tables to store their information (our model has about 500+ tables but there's less than 100 core table with heavy use). Also the projected ammout of information per client could be from small (few hundreds tuples/MB) to huge (few millions tuples/GB). > > One of the many questions we have is about performance of the db if we work with only one (using a ClientID to separete de clients info) or thousands of separate dbs. The management of the dbs is not a huge concert as we have an automated tool. In addition to the excellent advice from others, I'll speak from experience: The best model here, if you can implement it, is to implement shared tables for all customers, but have a way you can "break out" customers to their own database(s). This allows you to start with a single database, but to shard out your larger customers as they grow. The small customers will always stay on the same DB. That means you'll also treat the different customers as different DB connections from day 1. That way, when you move the large customers out to separate servers, you don't have to change the way the app connects to the database. If you can't implement shared tables, I'm going to say go for separate databases. This will mean lots of additional storage space -- the per-DB overhead by itself will be 100GB -- but otherwise you'll be grappling with the issues involved in having a million tables, which Joe Conway outlined. But if you don't have shared tables, your huge schema is always going to cause you to waste resources on the smaller customers. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance