PERF: Dematerialize topic_reply_count (PR #9769)

Instead of updating topic_reply_count on every post creation, deletion, and ownership change, calculate it from scratch during trust level promotions. Additionally, replace the topic_count + reply_count on the client with any_posts, as it was only ever compared to 0.

GitHub

the column is now useless, drop it from the db

We use camelCase on the client-side (except very few places) :wink:

    anyPosts

Why *2 and not just +1?

Looks like this is a new condition. Is it intended?

I think >= would be more correct here.

    return numReplied >= minReplied;

If I’m doing a +1, then > would be correct, no?

TL3 requirements checked for .public_posts https://github.com/discourse/discourse/pull/9769/files#diff-71b275fc6f97d344de4978707d0f2fdeL147

TL3 requirements checked for .public_posts https://github.com/discourse/discourse/pull/9769/files#diff-71b275fc6f97d344de4978707d0f2fdeL147

I’m always off by one :stuck_out_tongue:

TL2 didn’t as far as I know, but I guess it’s better that way :+1:

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/postgresql-12-update/151236/168