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

Use pre-Explain SQL for WithoutQueryVariables #15

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

chradcliffe
Copy link
Contributor

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

The current implementation of WithoutQueryVariables substitutes ? for any query variables and calls tx.Dialector.Explain, which can result in a lot of string allocations. This implementation avoids the substitution and uses whatever the default representation of the query parameters is for the SQL dialect.

Fixes #14

User Case Description

We had performance issues with the previous implementation of tracing with the WithoutQueryVariables option.

The current implementation of `WithoutQueryVariables` substitutes `?` for any query variables and
calls `tx.Dialector.Explain`, which can result in a lot of string allocations. This implementation
avoids the substitution and uses whatever the default representation of the query parameters is for
the SQL dialect.
@zstone12
Copy link
Collaborator

Looks good to me.
Thank you once again for your pull request.

@zstone12 zstone12 self-requested a review September 15, 2023 15:52
@zstone12 zstone12 merged commit 0e6d07e into go-gorm:master Sep 16, 2023
2 checks passed
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.

Add config option to trace raw tx.Statement.SQL.String() without applying tx.Dialector.Explain
2 participants