This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/mongo_indexes
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 8b08932b8f21dd6e9ab743ed7652c5ea5164a7c1
Author: Dave Brondsema <dbronds...@slashdotmedia.com>
AuthorDate: Fri Oct 14 13:06:37 2022 -0400

    add indexes to Post for update_stats() queries
---
 Allura/allura/model/discuss.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 49e0e4686..2c40db80f 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -512,7 +512,10 @@ class Post(Message, VersionedArtifact, ActivityObject, 
ReactableArtifact):
         indexes = [
             # used in general lookups, last_post, etc
             ('discussion_id', 'status', 'timestamp'),
-            'thread_id',
+            # for update_stats()
+            ('discussion_id', 'deleted', 'status'),
+            # for update_stats() and thread_id in general
+            ('thread_id', 'status', 'deleted'),
             # for find_posts/query_posts, including full_slug sort which is 
useful on super big threads
             ('deleted', 'discussion_id', 'thread_id', 'full_slug'),
         ]

Reply via email to