MiniProfiler / rack-mini-profiler

Profiler for your development and production Ruby rack apps.
MIT License
3.74k stars 406 forks source link

[Enhancement] Capture the number of rows instantiated #585

Closed kbrock closed 12 months ago

kbrock commented 1 year ago

Goal

This uses active support notifications to capture the number of active record objects instantiated.

Useful?

If you just look at the number of queries, doing a bunch of outer joins looks like a great optimization.

But if you take into account the amount of data brought back, it keeps that over simplification in check.

I have been using this for >7 years and it is a key metric for me. So I'm putting it out there and see if it is useful to others, as well.

Shortcoming

This only captures instantiation

Model.where(:category => 5).limit(20).select(:name) - captures Model.where(:category => 5).limit(20).pluck(:name) - doesn't capture

Since instantiations are a majority of our use cases, I've only seen a handful of cases where the pluck misrepresented a PR or an issue.

This is only for active record notifications

I only implemented this for ActiveSupport::Notifications. It could be done for the others, but I'd prefer to gauge demand before implementing this for every patch configuration.

This isn't in the ui

I use the command line to view the results, so I haven't coded this into the ui. If that is needed, would like a little help.