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

Load Tree Debug #45565

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Load Tree Debug #45565

wants to merge 19 commits into from

Conversation

gwincr11
Copy link
Contributor

@gwincr11 gwincr11 commented Jul 11, 2022

Summary

This builds off the Load Tree PR #45161 which introduced the tree of all the loaded records. I this pr I am adding a debug view that can be used to debug all loaded active record objects and see how they were loaded. Attached is a demo of it in action.

ar.debug.demo.mov

This is very much a starting point and one could imagine adding a lot more information to it, such as the sql query that loaded the record or the sql explain information.

Other Information

This is the first debug view for active record, I am not sure where it should go, how to test it or if this is even how the rail community would want it to work. You can test it out by adding this to you Application controller:

  ActiveRecord.load_tree_enabled = true
  ActiveRecord::Debugger.enable_debugging

and then this to a view or a layout:

<%= render "active_record_debugger/debugger" %>

It could also be a better looking interface, I am not sure how css should be brought into something like this and how to avoid fighting with site other stylesheets out there, which is why I left it out, completely open to ideas.

Motivation:
  As the first step in building out active record dynamic includes and
  the new load tree debug view as proposed in rails#45071 we need the load
  tree to be available.

  The load tree stores the siblings in order to allow for easy loading
  of association data to prevent n+1 queries automatically as shown in rails#45701.
  It also stores other information about the loaded records to allow for
  easy debugging of the load tree and traversal of the tree.

  There will be 2 follow up PR's to this, one re-introducing auto loading,
  or dynamic loading of associations. The second will be to add a debug
  view of the load tree.
…ater pr around a debugging view that is in progress.
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.

None yet

1 participant