Is there a performance penalty on using databases instead of schemas in a single PostgreSQL cluster?

All we need is an easy explanation of the problem, so here it is.

I m partitioning my problem using a Domain-Driven Design approach. Several databases arise with low or null coupling.

In the long term they will be separate databases on separate hosts, horizontally scaled. However, currently I do not need/want such an expensive deployment. I just plan to run the whole thing on a single PostgreSQL cluster. The development environment is another clear situation where having a single cluster is desirable.

Authors as Chris Richardson recommend using schemas in the near term however, I have found this implies rewriting part of the SQL code when logical replication is used to solve the couplings. I imagine he is using the term schema with MySQL in mind.

Using separate databases seem to be the perfect solution in terms of SQL code invariance but, does this imply a performance penalty on a sole cluster compared to a single database virtually segmented by schemas?

I have read this similar question but mine is clearly focused on performance penalty. I am clearly biased to segment the problem using databases from a logical point of view.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

If you don’t need to join data from several databases, splitting the data into multiple databases is the cleaner solution, and there should be no performance disadvantages.

Method 2

Yes. The main problem is that you can’t reuse connections. Which means that you will have more connection, which means that you will use more memory.

OTOH separate DBs means that each DB stats will be smaller.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply