Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWnlI-00083l-Uh for pgsql-performance@arkaria.postgresql.org; Thu, 07 May 2020 21:08:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jWnlH-0001UM-Jc for pgsql-performance@arkaria.postgresql.org; Thu, 07 May 2020 21:08:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWnlG-0001UF-VO for pgsql-performance@lists.postgresql.org; Thu, 07 May 2020 21:08:55 +0000 Received: from campbell-lange.net ([178.79.140.51]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWnlA-0005XQ-EU for pgsql-performance@lists.postgresql.org; Thu, 07 May 2020 21:08:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=69JaFQbYQ4wG2lMd3VDEWFDJ+/QSRLL907PdwA4x9qc=; b=uYg1xE5MdLyNWyA4NY4dTGvmd Ffe4Uz9diQ+aM9CJiPnhaO2d5nH0S3d+C/wt0aT61rVX2ow8Qff3m08EapBDMZjpsy70j36fnI0zL GRjVtExj1Epdagx5pl2+MkNxbvNpITc3tMI1CpEnepRueqhYmZiWck0Ymbn1XGISY4BIM=; Received: from 251.164.198.146.dyn.plus.net ([146.198.164.251] helo=rory-t450s) by campbell-lange.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWnl9-0007lx-Dy; Thu, 07 May 2020 21:08:47 +0000 Received: from rory by rory-t450s with local (Exim 4.92) (envelope-from ) id 1jWnl8-0004Vz-T9; Thu, 07 May 2020 22:08:46 +0100 Date: Thu, 7 May 2020 22:08:46 +0100 From: Rory Campbell-Lange To: Avinash Kumar Cc: "David G. Johnston" , samhitha g , pgsql-performance@lists.postgresql.org Subject: Re: pg_attribute, pg_class, pg_depend grow huge in count and size with multiple tenants. Message-ID: <20200507210846.GA17040@campbell-lange.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/05/20, Avinash Kumar (avinash.vallarapu@gmail.com) wrote: > >> Our application serves multiple tenants. Each tenant has the schema > >> with a few hundreds of tables and few functions. > >> We have 2000 clients so we have to create 2000 schemas in a single > >> database. > > That is one option but I wouldn't say you must. If you cannot get > > individual tables to be multi-tenant you are probably better off having one > > database per client on a shared cluster - at least given the size of the > > schema and number of clients. > > > I am working on a similar problem. > 1 database per each client may be a killer when you have a connection > pooler that creates a pool for a unique combination of (user,database). One of our clusters has well over 500 databases fronted by pg_bouncer. We get excellent connection "flattening" using pg_bouncer with per-database connection spikes dealt with through a reserve pool. The nice thing about separate databases is that it is easy to scale horizontally. Rory