-
-
Notifications
You must be signed in to change notification settings - Fork 779
Add a federated index to resolve mongo slow queries #5818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
arm4b
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting a PR to improve the performance case, appreciate the efforts 👍
Just left a few comments as looks like you're including changes from another PR.
|
There are some python linting issues failing in CI that need fixing. |
@armab Sorry, I reformatted the code, but I don't know why check failed |
arm4b
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chain312 !
I updated the PR for you.
I added a joint index to solve the problem of slow mong queries


Mongodb slow query
"op" : "query", "ns" : "st2.action_execution_scheduling_queue_item_d_b", "command" : { "find" : "action_execution_scheduling_queue_item_d_b", "filter" : { "handling" : false, "scheduled_start_timestamp" : { "$lte" : NumberLong("1668782450676922") } }, "sort" : { "scheduled_start_timestamp" : 1, "original_start_timestamp" : 1 }, "limit" : 1, "singleBatch" : true, "lsid" : { "id" : UUID("34a962b6-09d5-4745-9cf0-7ba006881362") }, "$db" : "st2", "$readPreference" : { "mode" : "primaryPreferred" } }This query takes 251ms. Through the sql query, it can be seen that the sql model structure is filter+sort+limit, and the index is built on the column of [sort]. That is, the joint index of scheduled_start_timestamp and original_start_timestamp is established. After the index is added, the query time is less than 20ms, and the cpu decreases by 11%,11 times faster action execution