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
This has been brought up here before #24330 but is still an issue occasionally. The application of these regular expressions can sometimes dominate the request time, including the SQL server processing the query and instantiating a lot of AR-objects as a result. I have had cases in my app where disabling sql_color has reduced request times for a request from 4.8 to 1.2 seconds.
Steps to reproduce
Generate a long sql query and send it through AR (e.g. find_by_sql)
Observe that a lot of time is spent in ruby case matching using Regexp.=== (for example using some profiler)
Narrow this down to inefficient regular expressions being applied by sql_color
Expected behavior
sql_color should not slow down query processing (in production)
Actual behavior
I am unsure.
Maybe sql_color can be configured (perhaps optionally) to be disabled in production, maybe the regular expressions can be made faster?
System configuration
Rails version: 6.0.2.1
Ruby version: 2.6.3
The text was updated successfully, but these errors were encountered:
@rafaelfranca@spjsschl Can I open a PR for this? I did the patch for it and used colorize_logging config to disable the unnecessary sql_color call happening when colorize_logging is disabled.
…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 fixesrails#38685 and removes
unnecessary invokation of `sql_color`
method when `colorize_logging` is disabled
This has been brought up here before #24330 but is still an issue occasionally. The application of these regular expressions can sometimes dominate the request time, including the SQL server processing the query and instantiating a lot of AR-objects as a result. I have had cases in my app where disabling
sql_color
has reduced request times for a request from 4.8 to 1.2 seconds.Steps to reproduce
find_by_sql
)Regexp.===
(for example using some profiler)sql_color
Expected behavior
sql_color
should not slow down query processing (in production)Actual behavior
I am unsure.
Maybe
sql_color
can be configured (perhaps optionally) to be disabled in production, maybe the regular expressions can be made faster?System configuration
Rails version: 6.0.2.1
Ruby version: 2.6.3
The text was updated successfully, but these errors were encountered: