Baterka Baterka - 3 years ago 104
MySQL Question

MySQL Size VS. Computing capabilities - Is bigger database better than more complex code?

In general, is bigger database better than more complex code?
When I have for example database full of users:

| ID | Username | Role |
| 01 | test1 | regular |
| 02 | test2 | admin |
| 03 | test3 | regular |

Is better save on database size by changing roles from text ones to ID's (regular = 0, admin = 1) and then in server-side program, when selecting many rows, change ID to text again for each row?

One is waste of space and one is waste of computing speed. What is better?

Answer Source

It depends on your application (of course). The most important thing to consider IMO is scale. If you have to scale to mega users you're going to blow the crud out of your database.

This is true with a lot of apps that use a shared service on the backend like SQL/NoSQL or queues. If you push the "work" to the back end then when you've got a dozen or a hundred servers you end up choking the backend.

That being said there is the inverse problem where (for instance) say you want to validate a user's password hash against a database. If you do the "skinny" save in the database you need end up searching (b tree or whatever) for the match. If you do the work ahead of time to store it in a hash table you can explicitly ask for it from the server. That's important if you are something like Facebook and have billions of potential matches.

Personally I'd try and keep as much of the work on the clients as possible but I am sure there are people who disagree with me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download