Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3DF8C632455 for ; Fri, 25 Jun 2010 21:03:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 71794-10 for ; Sat, 26 Jun 2010 00:02:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.9]) by mail.postgresql.org (Postfix) with ESMTP id AD5366321BE for ; Fri, 25 Jun 2010 21:02:57 -0300 (ADT) Received: from [75.197.236.239] (239.sub-75-197-236.myvzw.com [75.197.236.239]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0LqpOw-1P6bQV2uuo-00dgVn; Sat, 26 Jun 2010 02:02:54 +0200 Message-ID: <4C2543AB.90000@2ndquadrant.com> Date: Fri, 25 Jun 2010 20:02:51 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Kevin Grittner CC: tony@exquisiteimages.com, pgsql-performance@postgresql.org Subject: Re: Architecting a database References: <4C24E5E90200002500032B5A@gw.wicourts.gov> <4C24E7570200002500032B5D@gw.wicourts.gov> <4C24E7570200002500032B5D@gw.wicourts.gov> In-Reply-To: <4C24E7570200002500032B5D@gw.wicourts.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/WZ8BrAHMW7V365PMJ58hg1nf15o5E0Hei0dx DbYmoMV/oqWmZQ01DMfWflv4ZpSZ8Q45eygUxWUmPHMamZGsMK tJ2UjS1TYmFIQGq5LSfBpiddCXC576d X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/487 X-Sequence-Number: 39343 Kevin Grittner wrote: > A schema is a logical separation within a database. Table > client1.account is a different table from client2.account. While a > user can be limited to tables within a single schema, a user with > rights to all the tables can join between them as needed. You could > put common reference data in a public schema which all users could > access in addition to their private schemas My guess would be that this app will end up being best split by schema. I wonder whether it *also* needs to be split by database, too. 2000 clusters is clearly a nightmare, and putting all the client data into one big table has both performance and security issues; that leaves database and schema as possible splits. However, having 2000 databases in a cluster is probably too many; having 2000 schemas in a database might also be too many. There are downsides to expanding either of those to such a high quantity. In order to keep both those in the domain where they perform well and are managable, it may be that what's needed is, say, 50 databases with 40 schemas each, rather than 2000 of either. Hard to say the ideal ratio. However, I think that at the application design level, it would be wise to consider each client as having a database+schema pair unique to them, and with the assumption some shared data may need to be replicated to all the databases in the cluster. Then it's possible to shift the trade-off around as needed once the app is built. Building that level of flexibility in shouldn't be too hard if it's in the design from day one, but it would be painful bit of refactoring to do later. Once there's a prototype, then some benchmark work running that app could be done to figure out the correct ratio between the two. It might even make sense to consider full scalability from day one and make the unique client connection info host:port:database:schema. P.S. Very refreshing to get asked about this before rather than after a giant app that doesn't perform well is deployed. -- Greg Smith 2ndQuadrant US Baltimore, MD PostgreSQL Training, Services and Support greg@2ndQuadrant.com www.2ndQuadrant.us