Multi Tenant applications using PostgreSQL Row Level Security
PostgreSQL supports Row Level Security (RLS) so that applications can restrict who can see which records in a table either based in DB user name or based on Connection session variable. This feature can be used to implement discriminator based multi tenant where records for multiple customers are present in single table. This blog explains steps for implementation https://www.crunchydata.com/blog/row-level-security-for-tenants-in-postgres Advantage of this approach is that its easy to implement and day to day application development activities dont have to bother about breaking multi tenancy because code for applying discriminator is implemented at a framework that obtains connection from connection pool. Application developers dont have to modify individual SQL statement or even pass around tenant_id as a parameter in method calls. Good thing about RLS is that RLS policy can be applied to specific Roles in Postgres and these roles should be used by application connections wh...