basecamp / marginalia

Attach comments to ActiveRecord's SQL queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prepend_comment is breaking ActiveRecord's explain

anmolarora opened this issue · comments

When Marginalia::Comment.prepend_comment is set to true in a rails app, ActiveRecord explain stops showing the explain results in the rails console

Screenshot 2020-01-01 at 15 17 38

Environment

Database: PostgreSQL 10.10
Rails: 5.2.3
Ruby: 2.6.5
Marginalia: 1.8.0

Looks like the issue is on this line where rails filters out the queries for explain using regex.

https://github.com/rails/rails/blob/3c28e79b615f6937f5abdc433ff634d15cf2466f/activerecord/lib/active_record/explain_subscriber.rb#L24

Since for explain to work, the query needs to start with one of (with|select|update|delete|insert). And when you enable prepend_comment, the query starts with the comment.