Home > Back-end >  Is it ok to have more than 40 to 50 fields in a Postgres Table?
Is it ok to have more than 40 to 50 fields in a Postgres Table?

Time:04-03

I'm planning to use more than 40 to 50 columns in User table. the table will contain personal information, demographic information, lifestyle, etc. will there be an issue?

CodePudding user response:

of course there will be performance issue.
then table becomes larger it will consume more and more RAM and disk I/O
better strategy to divide table.
In main user table keep info that you retrieve almost every time: id, login, email, name.
Address info in another table.
demographic information and lifestyle in another tables so you don`t need to reread whole users table to get stats.
Also if you obligated to follow GDPR or something you should take care of separating personal info (which must be purged after some time) and statistic unpersonalized info that you can use for business purpose

CodePudding user response:

As your model requires that than it is fine. But I have a feeling that those stuffs could be separated to another referent tables.

For example User might be main table with personal informations related to user, something like username, first name, last name, email, password, etc.

lifestyle and other stuffs can go in another tables.

  • Related