Performance bar uses Sherlock for formatting queries, but the performance bar doesn't display whitespace
Our custom performance bar code does this:
def track_query(raw_query, bindings, start, finish)
query = Gitlab::Sherlock::Query.new(raw_query, start, finish)
query_info = { duration: query.duration.round(3), sql: query.formatted_query }
PEEK_DB_CLIENT.query_details << query_info
end
Specifically:
query = Gitlab::Sherlock::Query.new(raw_query, start, finish)
Every instance of Gitlab::Sherlock::Query
will generate a Ruby backtrace using caller_locations
, which is quite slow (especially for a lot of queries).
Further we use #formatted_query
in an attempt to display the SQL in a more readable manner. Unfortunately the performance bar displays the queries without newlines, probably as the result of using <pre>
without the right CSS settings.