I was wondering if it which is faster when trying to, for example, check how many posts are in a particular thread on a forum. Should I…
(a) Go through each post in the database with the particular thread ID, and count how many rows
or
(b) Add one to a separate column in the threads database every time a thread is made, and then query that single row
Thanks.
What’s wrong with having an index for the thread ID? Wouldn’t a simple COUNT expression grouped by the thread ID field suffice?
With any caching at all, this would be plenty fast from what I can tell.