Skip to content

Optimize Handler_read_rnd by removing ORDER BY clause #448

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

soulee-dev
Copy link
Contributor

@soulee-dev soulee-dev commented Aug 26, 2023

Problem

We observed that the Handler_read_rnd was continually increasing whenever __get_table_information was called upon starting PyMyRepl. The reason was found to be the usage of the ORDER BY clause on a non-indexed column within the function.

Solution

Since the table entries were empty, and ORDER BY was being used on a non-indexed column, this led to an increase in the Handler_read_rnd. As a remedy, we removed the ORDER BY clause from the SQL query and instead used Python's sort() method to sort the results. Since ORDINAL_POSITION is auto-incremental, this change will return the same sorted results as the original ORDER BY clause, without the associated performance penalty.

Changes

Removed the ORDER BY clause from the SQL query within __get_table_information.
Implemented sorting using Python's sort() method based on ORDINAL_POSITION.

Benefits

Reduces the overhead associated with using the ORDER BY clause on a non-indexed column.
Mitigates the increase in Handler_read_rnd, leading to improved performance.

Fixed: #445

@julien-duponchelle
Copy link
Owner

That's great !

@julien-duponchelle julien-duponchelle merged commit f524638 into julien-duponchelle:main Aug 26, 2023
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.

increasing handler_read_rnd
3 participants