O3-3003 (fix) slow queries with many JOINs by upgrading mariadb to version 10.11.7 #800
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MariaDB 10.8.2 runs unusably slow on queries with many JOINs. My previous attempt to fix this issue by tuning a DB parameter did not work. There were non-deterministic behaviors that I did not test for, and dev3 is still experiencing the same slowness on this REST endpoint. https://dev3.openmrs.org/openmrs/ws/rest/v1/queue-entry. More details documented in this ticket.
MariaDB's issue tracker has documented the many JOINs issue as well and has a fix available in later versions. I think upgrading would be the best way to fix this issue (rather than trying to further tune DB parameters). 10.11.7 is currently the newest version in 10.x releases.
Testing done:
More detailed repro steps documented here. Summary:
I confirmed that the above steps repros the issue in 10.8.2 and confirmed that it doesn't happen on 10.11.7 after ~10 attempts.
I have tested that upgrading mariaDB 10.8.2 to 10.11.7 needs no further upgrade steps (the DB storage files are compatible). However, when I get the DB to be stuck in the bad state in 10.8.2, upgrading to 10.11.7 does not automatically fix this issue. Instead, I have to manually do a db dump and restore it to fix it. (I might need someone with access to dev3 DB to help me with that later).