pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ravi Krishna <srkrishna1@comcast.net>
Cc: PostgreSQL Mailing Lists <pgsql-general@postgresql.org>
Subject: Re: Table partitioning for cloud service?
Date: Thu, 21 May 2020 17:49:37 -0400
Message-ID: <ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net> (raw)
In-Reply-To: <CAKyoTgYk+_QpsT40coRfx7HdFevZnNH-8o0yJAxWeJO_rNdQ_A@mail.gmail.com>
References: <29ACFF1C-FF57-4A36-B3B4-F92C817D3AE8@brewstersoft.com>
	<bbcaac9d-4da1-d087-c845-5580b6c7a709@aklaver.com>
	<4F4DEDE2-7ABD-4652-99FE-70C435518AC3@brewstersoft.com>
	<CAFNqd5XP0rZQoV4s-shdgunjhUur1pxc2HwJFM=4USAguMNpQw@mail.gmail.com>
	<CAKyoTgYk+_QpsT40coRfx7HdFevZnNH-8o0yJAxWeJO_rNdQ_A@mail.gmail.com>

> 
> The database/schema per tenant solution can be tedious when you want to modify something on the structure and you have numerous tenants.
> Therefore I used the "tables with tenant_id" version in a similar situation but with a slight twist. One of the biggest issue of this solution is that if you forget to add the tenant_id to the where clause you are going to reveal one tenant's data to another.
> I came up with the solution that the database user have no privileges for accessing the base tables. Instead of that I generate views for each tenant and they can access their own data in the underlying table through these views. Now if forget to address the right tenant in my client code(it still happens sometimes) and try to directly access the base tables I get a strongly worded reminder from the server.

1. If you have 50 tables and say 100 tenants, we are talking about 5,000 views. I am not sure 
    whether it is any more elegant than having 100 schemas.
2. In your approach you can do any phased DDL upgrade.  It is typical to do rolling upgrades
    in a multi tenant databases, starting with least risky tenant.






view thread (13+ messages)  latest in thread

Message-ID: <ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net>
Permalink:  ../ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net/
Also on:    postgresql.org/message-id/ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: srkrishna1@comcast.net
  Subject: Re: Table partitioning for cloud service?
  In-Reply-To: <ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net>
  References: <29ACFF1C-FF57-4A36-B3B4-F92C817D3AE8@brewstersoft.com> <bbcaac9d-4da1-d087-c845-5580b6c7a709@aklaver.com> <4F4DEDE2-7ABD-4652-99FE-70C435518AC3@brewstersoft.com> <CAFNqd5XP0rZQoV4s-shdgunjhUur1pxc2HwJFM=4USAguMNpQw@mail.gmail.com> <CAKyoTgYk+_QpsT40coRfx7HdFevZnNH-8o0yJAxWeJO_rNdQ_A@mail.gmail.com> <ECD49B34-DFF3-4260-8AF1-CC1702E2A0EA@comcast.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox