-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: slow conversation list queries [WPB-11808] #3080
fix: slow conversation list queries [WPB-11808] #3080
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/candidate #3080 +/- ##
=====================================================
+ Coverage 52.55% 52.58% +0.02%
=====================================================
Files 1318 1318
Lines 51445 51458 +13
Branches 4772 4774 +2
=====================================================
+ Hits 27039 27060 +21
+ Misses 22445 22437 -8
Partials 1961 1961
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportBranch report: ✅ 0 Failed, 3147 Passed, 106 Skipped, 30.79s Total Time |
Quality Gate passedIssues Measures |
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
Paginated conversation list queries are very slow when there are many conversations and/or messages in the database.
Causes (Optional)
I noticed that the biggest impact on the execution time was the nested query to get last message id for the conversation.
Also, every time the draft message is upserted, even with the same value, then conversation list query is notified and reloads.
Solutions
Replaced nested query with just using
MAX
- we already makeGROUP BY
so when usingMAX(LastMessage.creation_date)
it will left join the message with largestcreation_date
which is the last one, no need to make a nested query to get that.For draft messages, do not make update query when nothing changed and make it inside the transaction to rollback it if nothing is changed - thanks to that no other query will be notified about this update unnecessarily.
Testing
Test Coverage (Optional)
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.