You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For current ParsedQuery class:
Each function in is_select, is_explain, is_show will format sql statement by calling sqlparse.format function. But it takes quite long (~0.332s for one call). So you need to call 3 times for checking is_read_only_query --> Total time: 0.9818s
Solution
I wrote an PR to reduce time for checking is_read_only_query at #29557
Please help me to review it
How to reproduce the bug
Go to a dashboard and check time for loading result
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
I have searched Superset docs and Slack and didn't find a solution to my problem.
I have searched the GitHub issue tracker and didn't find a similar bug report.
I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
The text was updated successfully, but these errors were encountered:
Hey there, @vuongtlt13! 👋 I'm here to assist you with any bugs, questions, or contributions. Let's squash those bugs together!
The pull request you mentioned introduces the is_select_query method and uses it within the is_readonly_query method to improve performance. This change reduces the number of times the sqlparse.format function is called, which significantly decreases the time required to check if a query is read-only.
This change ensures that the is_readonly_query method only calls sqlparse.format once, reducing the total time from approximately 0.9818s to 0.3278s [1].
Additionally, there are existing unit tests for the is_readonly_query method that cover various scenarios for both SQL and KQL queries. These tests ensure that the method correctly identifies read-only queries [2][3][4].
You can review the pull request and run the tests to verify the improvements.
Bug description
Problem
First, I have a sql statement with length is 17121. I need check **is_read_only_query**Logic for checking is_read_only_query is at superset/db_engine_specs/base.py#L2027
![image](https://private-user-images.githubusercontent.com/14292473/347719785-f184d354-8639-44ad-92cf-7555a4c2c153.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwNzUyNDcsIm5iZiI6MTcyNTA3NDk0NywicGF0aCI6Ii8xNDI5MjQ3My8zNDc3MTk3ODUtZjE4NGQzNTQtODYzOS00NGFkLTkyY2YtNzU1NWE0YzJjMTUzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDAzMjkwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdlOTFkMDJhMmEwNzNjYTU2ZTkwZTU3YzM1ZGQ3N2I5MDc0MTE3N2ZjNDM0NjFiYzIwMzI1MmY1NjAxOTQ4MmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MRiToEr5Lmh9eQtR44yAs4NrcEVy5n0HjluZQCbJHdU)
Test result
As you can see:
Each function in is_select, is_explain, is_show will format sql statement by calling sqlparse.format function. But it takes quite long (~0.332s for one call). So you need to call 3 times for checking is_read_only_query --> Total time: 0.9818s
Solution
I wrote an PR to reduce time for checking is_read_only_query at #29557
Please help me to review it
How to reproduce the bug
Go to a dashboard and check time for loading result
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: