diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c8e03e0e48..7d456f91f5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,8 @@ Added #5778 #5789 #5817 #5795 #5830 #5833 #5834 #5841 #5840 #5838 #5842 #5837 #5849 #5850 Contributed by @cognifloyd +* Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805 + 3.8.0 - November 18, 2022 ------------------------- diff --git a/st2common/st2common/models/db/execution_queue.py b/st2common/st2common/models/db/execution_queue.py index 8db0993363..a45267a4d7 100644 --- a/st2common/st2common/models/db/execution_queue.py +++ b/st2common/st2common/models/db/execution_queue.py @@ -77,6 +77,11 @@ class ActionExecutionSchedulingQueueItemDB( {"fields": ["liveaction_id"], "name": "lv_ac_id"}, {"fields": ["original_start_timestamp"], "name": "orig_s_ts"}, {"fields": ["scheduled_start_timestamp"], "name": "schd_s_ts"}, + # Adding a union index speeds up the query action_execution_scheduling_queue_item_d_b + { + "fields": ["scheduled_start_timestamp", "original_start_timestamp"], + "name": "schd_orig_s_ts", + }, ] }