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

Improved the query parsing for table access statistics #31

Merged
merged 5 commits into from
May 30, 2023

Conversation

onukristo
Copy link
Contributor

@onukristo onukristo commented May 19, 2023

Context

Changed

  • Implemented a timeout and interruption for TAS SQL parsing.
    Complex queries in one of our services created long duration heavy CPU burn.

  • Query parsing will use JSQLParser complex parsing immediately.
    Before, our implementation was using simple parsing. And JSQLParser implementation tried by default simple first
    and then complex, if simple failed.
    Performance tests showed simple parsing for simple queries, is not noticeably faster for simple queries.

  • Created a mechanism for a service to provide parsed query information itself and thus skip the query parsing.
    It can be used for complex queries where parsing is slow or for queries which jsqlparser can not handle.
    The mechanism can be used via TableAccessStatisticsParsedQueryRegistry interface.

  • Added more flexibility around query parsing via TasQueryParsingListener and TasQueryParsingInterceptor.

  • Supporting parsing queries with on conflict (...) clause with multiple parameters.
    We can remove our own solution, when next JSQLParser version would support it.

Checklist

@onukristo onukristo requested a review from a team as a code owner May 19, 2023 08:40
@onukristo onukristo added the change:standard Not an emergency or impactful change label May 19, 2023
@onukristo onukristo changed the title Sql parse fixes Improved the query parsing for table access statistics May 19, 2023
The library is pretty good, but some services have few queries, it can not parse. Also, sometimes the parsing can take so long,
that it will create latency spikes or cpu burns.

In those case, you can override/control the parsing via `TasQueryParsingInterceptor` and `TasParsedQueryRegistry`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe provide an example here as well how to do it?

@onukristo onukristo merged commit 395bfa2 into master May 30, 2023
@mscott-tw mscott-tw deleted the sql_parse_fixes branch February 15, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:standard Not an emergency or impactful change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants