"comment count" query in getForumStatistics() in \Drupal\forum\ForumManager is not limited to forum terms

Created on 7 July 2009, over 15 years ago
Updated 15 May 2024, 6 months ago

The query being executed in forum_get_forums computes the topic_count and comment_count for ALL taxonomy-terms, not just the ones in the forum vocabulary. This is a performance issue if you have many non forum nodes.

In my setup (albeit with mostly forum nodes) this makes almost a 10% differencein query-time: 310ms vs. 283ms.
(total nodes=11724, total comments=123459 / forum nodes=11715, forum comments=118518)
(28 forum terms / 364 terms)

This patch adds a AND r.tid IN ($forum_terms) to the query. Since I am not a programmer, the foreach-loop can certainly be made nicer. This was tested with mysql, I don't know about pg.

Please review.

🐛 Bug report
Status

Needs work

Version

1.0

Component

forum.module

Created by

🇩🇪Germany softrusher

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • needs profiling

    It may affect performance, and thus requires in-depth technical reviews and profiling.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024