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

Disable colorize logging of SQL and reduce unnecessary invocation of sql_color matching #38690

Merged

Conversation

abhaynikam
Copy link
Contributor

When the colorize_logging is disabled, logs do not colorize the SQL queries. But the sql_color method is always invoked which due to regex matching results in slow queries.

This PR fixes #38685 and removes unnecessary invocation of sql_color method when colorize_logging is disabled

Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

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

This is in the right direction but we should expose this

name = colorize_payload_name(name, payload[:name])
sql = color(sql, sql_color(sql), true)
if colorize_logging
name = colorize_payload_name(name, payload[:name])
Copy link
Member

Choose a reason for hiding this comment

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

Do this need to be inside the if. color will take care of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rafaelfranca I did necessary changes for it. Please have a look. Thanks

…sql_color matching

When the `colorize_logging` is disabled,
logs do not colorize the SQL queries.
But the `sql_color` method is always
invoked which due to regex matching results
in slow queries.

This PR fixes rails#38685 and removes
unnecessary invokation of `sql_color`
method when `colorize_logging` is disabled
@abhaynikam abhaynikam force-pushed the 38685-add-option-to-disable-sql-color branch from d79aa05 to 85b5cd3 Compare March 11, 2020 05:36
@rafaelfranca rafaelfranca merged commit 795140d into rails:master Mar 12, 2020
rafaelfranca added a commit that referenced this pull request Mar 12, 2020
…-sql-color

Disable colorize logging of SQL and reduce unnecessary invocation of sql_color matching
@abhaynikam abhaynikam deleted the 38685-add-option-to-disable-sql-color branch March 12, 2020 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql_color is slow for long sql queries
2 participants