Database speed optimization: few tables with many rows, or many tables with few rows?

前端 未结 7 923
鱼传尺愫
鱼传尺愫 2021-01-19 07:23

I have a big doubt.

Let\'s take as example a database for a whatever company\'s orders.

Let\'s say that this company make around 2000 orders per month, so, a

7条回答
  •  情深已故
    2021-01-19 08:01

    I agree that smaller tables are faster. But it depends on your business logic if it makes sense to split a single entity over multiple tables. If you need a lot of code to manage all the tables than it might not be a good idea.

    It also depends on the database what logic you're able to use to tackle this problem. In Oracle a table can be partitioned (on year for example). Data is stored physically in different table spaces which should make it faster to address (as I would assume that all data of a single year is stored together)

    An index will speed things up but if the data is scattered across the disk than a load of block reads are required which can make it slow.

提交回复
热议问题