Home > Back-end >  Would it make sense to put booleans in their own tables in order to save space?
Would it make sense to put booleans in their own tables in order to save space?

Time:06-19

Let's say you have a table called "user" with 1.000.000 records.

In this table you have a column named "banned". If the cell has a value of "true" this means that the user has been banned and can no longer access their account.

However out of the 1.000.000 users only 10.000 have ever been banned, which means that there are 990.000 records for which the storage that the column "banned" has been taking up has been somewhat wasted.

Wouldn't it make more sense to have a seperate table that stores the id's of the 10.000 users that have been banned, in order to save space?

CodePudding user response:

It depends. You can't follow this column segregation strategy to minimize the storage without the tradeoff. Performance and latency will be the two major factor directly impacted by this approach. At the end you need collective data to make the decision.

How you can collect the data?

You can aggregate that either directly at database level by joining the tables or at application level by invoking separate network calls to collect the data from different tables.

  • Related