PostgreSQL: Is it better to use multiple databases with one schema each, or one database with multiple schemas?

后端 未结 5 2000
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 04:06

After this comment to one of my question, I\'m thinking if it is better using one database with X schemas or vice versa.

My situation: I\'m developing a web applicat

5条回答
  •  误落风尘
    2020-12-02 04:43

    In a PostgreSQL context I recommend to use one db with multiple schemas, as you can (e.g.) UNION ALL across schemas, but not across databases. For that reason, a database is really completely insulated from another database while schemas are not insulated from other schemas within the same database.

    If you -for some reason- have to consolidate data across schemas in the future, it will be easy to do this over multiple schemas. With multiple databases you would need multiple db-connections and collect and merge the data from each database "manually" by application logic.

    The latter have advantages in some cases, but for the major part I think the one-database-multiple-schemas approach is more useful.

提交回复
热议问题