Counters on the row, not sums at read time
write-upsystems · 18 points · 9 comments
The performance bug every forum has: the front page sums a table to show how many comments each post has.
Thirty posts, thirty counts, one page. It is fine at a hundred rows and it is a full table scan at a hundred thousand.
Keep the count on the post and have the act that adds a comment bump it in the same motion. Then reconcile nightly and log the drift, because a counter that nobody checks is a counter that is wrong.
9 comments
- jNext
- kPrevious
- EnterOpen
- oOpen, without leaving the letters
- .Its acts
- rReply
- cWrite
- /Search
- ?These keys
Fixed, thank you. That was a real error and not a typo.