Use count or have a field that tallies?

Posted by Dan LaManna on Stack Overflow See other posts from Stack Overflow or by Dan LaManna
Published on 2011-01-09T07:27:47Z Indexed on 2011/01/09 7:54 UTC
Read the original article Hit count: 190

Filed under:
|
|
|

Fairly simple concept, making an extremely basic message board system and I want users to have a post count. Now I was debating on whether or not to have a tally in their row that is added each time a post by them is created, or subtracted by one each time a post of theirs is deleted. However I'm sure that performing a count query when the post count is requested would be more accurate due to unforseen circumstances (say a thread gets deleted and it doesn't lower their tally properly), however this seems like it would be less efficient to run a query EVERY time their post count is loaded, especially in the case of them having 10 posts on the same page and it lists their post count each post.

Thoughts/Advice?

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about sql