Resource icon

XF 1 Tip Rebuild user post counts (query)

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
24,439
Points
823

Reputation:

LQD submitted a new resource:

Rebuild user post counts (query) - A database query to rebuild all user post counts.

This will recalculate and update the post counts for all users at once. This is a large query that may take a while to finish.

Code:
UPDATE xf_user AS user
SET message_count = (
    SELECT COUNT(*)
    FROM xf_post AS post
    LEFT JOIN xf_thread AS thread ON (thread.thread_id = post.thread_id)
    WHERE post.user_id = user.user_id
    AND post.message_state = 'visible' AND thread.discussion_state = 'visible'
    GROUP BY post.user_id
);
If you have forums you wish to exclude from...

Read more about this resource...
 
Top