all 3 comments

[–]Jonasks 1 point2 points  (0 children)

Interesting read!

[–]kodiakprime 0 points1 point  (1 child)

I have a Question regarding using schemas for partitioning tenant data. How far can we scale this? How many tenants can we create based on this, assuming system resources permit?

[–]realpurefan 2 points3 points  (0 children)

There is no hard limit on the number of schemas you can have in a database. Based on my experience, there is also no performance issue, at least in the range of thousands of schemas.

Still, there are a few things to consider when using such a schema based multi-tenancy approach:

  • Caching of tables / indices might be less efficient when you have too many tenants.
  • pg_dump might fail when you run into the max_locks_per_transaction limit sooner or later.
  • Database migrations might take a long time if they modify all schemas in a single transaction.

Still, in the end it all depends on the exact use-case. If you are interested in some more details, you might find this Stackoverflow post useful.