php - MySQL: count rows versus save number of rows in a table -


I got a little performance question ..

There are three tables in my DB: users, between them I want to show the choice for each article on the article and a table user's username (surname preferred) on an index site for relationships.

Currently I want to add the number of likes to my articles table Save and add 1 plus or minus if it changes

Is this a better way to count the rows for each article? With every refresh of the index site, DB should have xx rows counting xx articles.

Thank you for your help!

There are two possible approaches:

1 - You run the calculation query of each time So your result is automatically updated (this is a problem for the display? I do not think this should be ... especially if you have an index on the Users_articles table on the Article ID field.)

2 - You can use the trigger to update your field on the article table, every time when users_articles are in the rhythm Anyone can remove, update, or join (it is really difficult for some reasons?)

What you can do to choose what happens in the second case when you want results, it is faster, In the past, your updates are fast.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -