-
Notifications
You must be signed in to change notification settings - Fork 898
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
Avoid N+1 queries by including snapshots #13833
Avoid N+1 queries by including snapshots #13833
Conversation
Avoid N+1 queries by including snapshots
@kbrock so this originates in templates list, when I select 1 templates and choose provision VM. With 70k templates this was doing 70k SQL queries, so it took like 8 minutes to load the VM provision workflow page. But for 70k images, each :include takes about 6s to load, which results in like 30s and then create_hash_struct_from_vm_or_template take 1ms, so 70s for 70k templates. So this still takes about 1.5 minute to load. So it's pretty bad we need to load 70k AR object + N*70k included objects. Just to verify if 1 template is allowed. :-) So a bigger rewrite will be needed in this area I suppose. :-) if I go to provision from instance list, that is even worse, several n+1 here, that goes also through genealogy, so we probably can't :include that. This repeats for every template:
but if I remember correctly, this doesn't have any search and will try to print me all 70k templates on 1 page? also it's strange that the each template list has a different code
|
Checked commit Ladas@41a55af with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
A few thoughts from chat with ladas: may be able to use Vm.select(:name, :v_total_snapshots).each {|v| puts "#{v.name}: #{v.v_total_snapshots}"}
The method may be able to |
The problem is we don't have a good way of adding Think refactoring may allow us to get the |
this PR fixes just the n+1, rest is covered in #14050 |
Avoid N+1 queries by including snapshots. v_total_snapshots needs the snapshots to be loaded