MySQL: Many tables or many databases?

前端 未结 9 501
陌清茗
陌清茗 2020-11-30 20:40

For a project we having a bunch of data that always have the same structure and is not linked together. There are two approaches to save the data:

  • Creating a n
9条回答
  •  一生所求
    2020-11-30 21:25

    I don't know mysql very well, but I think I'll have to give the standard performance answer -- "It depends".

    Some thoughts (dealing only with performance/maintenance, not database design):

    • Creating a new database means a separate file (or files) in the file system. These files could then be put on different filesystems if performance of one needs to be separate from the others, etc.
    • A new database will probably handle caching differently; eg. All tables in one DB is going to mean a shared cache for the DB, whereas splitting the tables into separate databases means each database can have a separate cache [obviously all databases will share the same physical memory for cache, but there may be a limit per database, etc].
    • Related to the separate files, this means that if one of your datasets becomes more important than the others, it can easily be pulled off to a new server.
    • Separating the databases has an added benefit of allowing you to deploy updates one-at-a-time more easily than with the single database.

    However, to contrast, having multiple databases means the server will probably be using more memory (since it has multiple caches). I'm sure there are more "cons" for the multi-database approach, but I am drawing a blank now.

    So I suppose I would recommend the multi-database approach. Obviously this is only with the understanding that there may very well be a better "database-designy" way of handling whatever you are actually doing.

提交回复
热议问题