sql - Using multiple tables in MySQL and/or multiple columns for a Rails application -


I'm thinking about what is the best practice to create unnecessary columns in a MySQL database Because I have a user table in my database but I also want to be able to display many statistics about each individual user. These figures may include how many times the user has communicated with another model or how many messages are there.

Does it affect performance to calculate all records of a particular object (such as a message)? Or is it better to create a redundant column in the user table, which is called the total message, every time a message is added / removed? Thanks, this is confusing me for a while.

short answer: both

of thumb As a rule, I do not like to create and update data that can be calculated on the fly (i.e. count). Therefore, I refrain from adding those unnecessary data until you achieve performance constraints and adjust accordingly.

You can always add retrospective statistics based on user activity, so that you only need your application "Futility is absolutely necessary to you."

Adding unnecessary data can improve your performance , But it does not fit all the solutions of a size anytime and you can hurt the overall performance if you are constantly trying to calculate and update the usage values. On the fly with the barrier can be calculated.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -