Re: How to restrict schema size per tenant

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: niraj nandane <niraj(dot)nandane(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: How to restrict schema size per tenant
Date: 2024-07-05 15:33:33
Message-ID: cacb3b0efc193defb8e595566c9b892833b79341.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, 2024-07-05 at 20:03 +0530, niraj nandane wrote:
> We are using Postgres schema based tenancy approach for our SaaS application.
> We create schema per tenant. We have Postgres instance in HA mode.
> We have multiple micro services and each service have its own database.
> For eg. Auth service have auth database, audit have audit. Inside each database,
> we create schema per tenant. We want to restrict usage to 10GB per tenant combined
> across all database. Is there any tool or built in way to monitor this in Postgres?

I don't know any. You'll have to run a query like

SELECT sum(pg_total_relation_size(t.oid)),
s.nspname
FROM pg_class AS t
RIGHT JOIN pg_namespace AS s
ON t.relnamespace = s.oid
WHERE NOT s.nspname LIKE ANY (ARRAY['pg\_catalog','pg\_toast%','information\_schema','pg\_temp%'])
GROUP BY s.nspname;

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2024-07-05 15:41:29 Re: How to restrict schema size per tenant
Previous Message niraj nandane 2024-07-05 14:33:14 How to restrict schema size per tenant