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

Prevents N+1 SQL queries in miq_request_workflow.rb #17354

Merged

Commits on Apr 26, 2018

  1. Handle writable_storages in miq_request_workflow better

    The MiqPreloader.preload call was added prior to the usage of
    `.writable_storages` for the miq_request_workflow.rb.  When
    writable_storages was called, it would make a new call to the database
    every time for each of the storages, which was not ideal.
    
    This change makes it so that the writable_storages method will first
    check to see if the proper data is already loaded, and if so, just use
    that.  Otherwise, it will do the query as normal.
    
    The other change was to change the MiqPreloader.preload to include the
    `host_storages`, which properly applies the loaded records needed for
    the changes to the `host` model to work.
    NickLaMuro committed Apr 26, 2018
    Configuration menu
    Copy the full SHA
    b77f060 View commit details
    Browse the repository at this point in the history
  2. Avoid N+1 in get_selected_hosts

    `.load_ar_obj` will defer to `.load_ar_objs` when it is passed an array,
    which will do a `.collect` call to `load_ar_obj` in return.  This is a
    typical N+1, so this change takes the constantize code from
    `.load_ar_obj` and applies it to the `allowed_hosts` to make a single
    SQL call to for the needed hosts.
    NickLaMuro committed Apr 26, 2018
    Configuration menu
    Copy the full SHA
    d986cb6 View commit details
    Browse the repository at this point in the history