Skip to content
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

O3-3003 (fix) slow queries with many JOINs by upgrading mariadb to version 10.11.7 #800

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

chibongho
Copy link
Contributor

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:

  • run dockerized mariaDB with the desired version
  • restore a DB dump with ~10000 queue entry rows
  • Flush table and perform a query joining 40 tables. Rinse and repeat this step as it sometimes takes a few tries to get the DB to get stuck in a bad state that runs the query slowly.

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).

Copy link
Member

@mseaton mseaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot better than adding that optimizer-search-depth parameter in! Defer to @ibacher on committing and actually applying this to dev3

Copy link
Member

@mogoodrich mogoodrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me, assumedly that "optimizer-search-depth" might have been contributing to the problem as well?

@mogoodrich
Copy link
Member

Oh, nvm, I see @mseaton 's comment about optimizer-search-depth... and, yes, defer to @ibacher for the final say.

@chibongho chibongho merged commit 7390409 into main Apr 3, 2024
7 checks passed
@pirupius pirupius deleted the O3-3003 branch April 29, 2024 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants