Skip to content
0:00 / 0:00

#postgresql#django#multi-tenancy

Using Postgres schemas to separate data of your SaaS application in Django — Mikuláš Poul

EuroPython Conference

36K subscribers • 31 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 in engineering communities.

Intermediate. Assumes working knowledge.

338 views12 months ago1 recommendation

Databases and dataWeb developmentPostgresSoftware architecture

Mikuláš Poul explains how to use PostgreSQL schemas to separate customer data in multi-tenant Django SaaS applications for better security and performance.

[EuroPython 2025 — South Hall 2B on 2025-07-18] 🎤 *Using Postgres schemas to separate data of your SaaS application in Django by Mikuláš Poul* 🔗 ep2025.europython.eu/session/using-postgres-schemas-to-separ… 📝 Abstract: Every SaaS will come against the same issue at one point - how to make sure to only show a customer's data to only that specific customer? And it's not just a security problem, but a performance problem as well. At scale, even with indexes, selecting just the appropriate data can become slow on massive tables. The "naive" approach is to have a table of customers, and link every other table using foreign keys, and always filter based on the current customer. This approach works fine, and with the library django-scope is pretty safe, but the filter still always needs to be provided and all the data is still in the same physical database table. Database segregation to the rescue! PostgreSQL has a feature called schemas, which almost acts like a database within a database - each has its own tables and indexes, and you can have many different schemas within one database. In this talk I will introduce you to the django-tenants library, which utilizes these schemas to implement tenanting. Django-tenants introduces two types of apps, shared apps containing data accessible for all tenants, and tenanted apps specific to one tenant. The data in the tenanted app is only available while the tenant is active, usually based on a subdomain. The django models then work exactly like before, but only the correct data will be returned without any filtering. In the talk, after walking through a simplified setup of the problem, we'll look at how much simpler django-tenants can make our life while implementing a SaaS application, but also look at certain new and more exciting problems it can bring. --- This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: creativecommons.org/licenses/by-nc-sa/4.0/

Why it's here

1 person recommends this

What people say. Listed in a curated collection of the best PostgreSQL conference talks and podcasts.

u/TechTalksWeeklyin r/PostgreSQL • Recommends

The Awesome List Of Postgres Conference Talks & Podcasts Of 2025 Hello r/postgres! As part of Tech Talks Weekly newsletter, I put together an awesome list of Postgres conference talks & podcasts published in 2025 (so far). This list is based on what popped up in my newsletter throughout the year and I hope you like it! # Conference talks *Ordered by view count* 1. [**"You don't need Elasticsearch! Fuzzy Search with PostgreSQL and Spring Data by Thomas Gräfenstein"**] ⸱ **+7k views** ⸱ 02 Sep 2025 ⸱ 00h 42m 23s 2. **"Bulk data processing and PostgreSQL thingy by Yingkun Bai"** ⸱ **+1k views** ⸱ 20 Jan 2025 ⸱ 00h 51m 58s 3. [**"How to accelerate GenAI projects using Knowledge Bases On P…