Skip to content

Instantly share code, notes, and snippets.

@Ladas
Last active May 10, 2018 07:38
Show Gist options
  • Save Ladas/cc38dce9f7254a40a3ff5d021200d93b to your computer and use it in GitHub Desktop.
Save Ladas/cc38dce9f7254a40a3ff5d021200d93b to your computer and use it in GitHub Desktop.
slow scoped_search query
SELECT "vms".* FROM "vms"
INNER JOIN "taggings" ON "taggings"."taggable_id" = "vms"."id" AND "taggings"."taggable_type" = $1
INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id"
WHERE "vms"."type" IN ('ManageIQ::Providers::CloudManager::Vm',
'ManageIQ::Providers::Google::CloudManager::Vm',
'ManageIQ::Providers::Amazon::CloudManager::Vm',
'ManageIQ::Providers::Azure::CloudManager::Vm',
'ManageIQ::Providers::Openstack::CloudManager::Vm',
'ManageIQ::Providers::Vmware::CloudManager::Vm')
AND "vms"."template" = $2
AND (tags.name = '/managed/environment/prod'
OR tags.name = '/managed/environment/prod')
[["taggable_type", "VmOrTemplate"], ["template", "f"]]
ManageIQ::Providers::CloudManager::Vm.search_for("(tag = /managed/environment/prod OR tag = /managed/environment/prod) AND name ~ bronagh%")
SQL (1.8ms) SELECT "vms"."id" AS t0_r0, "vms"."vendor" AS t0_r1, "vms"."format" AS t0_r2, "vms"."version" AS t0_r3, "vms"."name" AS t0_r4, "vms"."description" AS t0_r5, "vms"."location" AS t0_r6, "vms"."config_xml" AS t0_r7, "vms"."autostart" AS t0_r8, "vms"."host_id" AS t0_r9, "vms"."last_sync_on" AS t0_r10, "vms"."created_on" AS t0_r11, "vms"."updated_on" AS t0_r12, "vms"."storage_id" AS t0_r13, "vms"."guid" AS t0_r14, "vms"."ems_id" AS t0_r15, "vms"."last_scan_on" AS t0_r16, "vms"."last_scan_attempt_on" AS t0_r17, "vms"."uid_ems" AS t0_r18, "vms"."retires_on" AS t0_r19, "vms"."retired" AS t0_r20, "vms"."boot_time" AS t0_r21, "vms"."tools_status" AS t0_r22, "vms"."standby_action" AS t0_r23, "vms"."power_state" AS t0_r24, "vms"."state_changed_on" AS t0_r25, "vms"."previous_state" AS t0_r26, "vms"."connection_state" AS t0_r27, "vms"."last_perf_capture_on" AS t0_r28, "vms"."registered" AS t0_r29, "vms"."busy" AS t0_r30, "vms"."smart" AS t0_r31, "vms"."memory_reserve" AS t0_r32, "vms"."memory_reserve_expand" AS t0_r33, "vms"."memory_limit" AS t0_r34, "vms"."memory_shares" AS t0_r35, "vms"."memory_shares_level" AS t0_r36, "vms"."cpu_reserve" AS t0_r37, "vms"."cpu_reserve_expand" AS t0_r38, "vms"."cpu_limit" AS t0_r39, "vms"."cpu_shares" AS t0_r40, "vms"."cpu_shares_level" AS t0_r41, "vms"."cpu_affinity" AS t0_r42, "vms"."ems_created_on" AS t0_r43, "vms"."template" AS t0_r44, "vms"."evm_owner_id" AS t0_r45, "vms"."ems_ref_obj" AS t0_r46, "vms"."miq_group_id" AS t0_r47, "vms"."linked_clone" AS t0_r48, "vms"."fault_tolerance" AS t0_r49, "vms"."type" AS t0_r50, "vms"."ems_ref" AS t0_r51, "vms"."ems_cluster_id" AS t0_r52, "vms"."retirement_warn" AS t0_r53, "vms"."retirement_last_warn" AS t0_r54, "vms"."vnc_port" AS t0_r55, "vms"."flavor_id" AS t0_r56, "vms"."availability_zone_id" AS t0_r57, "vms"."cloud" AS t0_r58, "vms"."retirement_state" AS t0_r59, "vms"."cloud_network_id" AS t0_r60, "vms"."cloud_subnet_id" AS t0_r61, "vms"."cloud_tenant_id" AS t0_r62, "vms"."raw_power_state" AS t0_r63, "vms"."publicly_available" AS t0_r64, "vms"."orchestration_stack_id" AS t0_r65, "vms"."retirement_requester" AS t0_r66, "vms"."tenant_id" AS t0_r67, "vms"."resource_group_id" AS t0_r68, "vms"."deprecated" AS t0_r69, "vms"."storage_profile_id" AS t0_r70, "vms"."cpu_hot_add_enabled" AS t0_r71, "vms"."cpu_hot_remove_enabled" AS t0_r72, "vms"."memory_hot_add_enabled" AS t0_r73, "vms"."memory_hot_add_limit" AS t0_r74, "vms"."memory_hot_add_increment" AS t0_r75, "vms"."hostname" AS t0_r76, "tags"."id" AS t1_r0, "tags"."name" AS t1_r1 FROM "vms" LEFT OUTER JOIN "taggings" ON "taggings"."taggable_id" = "vms"."id" AND "taggings"."taggable_type" = $1 LEFT OUTER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" WHERE "vms"."type" IN ('ManageIQ::Providers::CloudManager::Vm', 'ManageIQ::Providers::Google::CloudManager::Vm', 'ManageIQ::Providers::Amazon::CloudManager::Vm', 'ManageIQ::Providers::Azure::CloudManager::Vm', 'ManageIQ::Providers::Openstack::CloudManager::Vm', 'ManageIQ::Providers::Vmware::CloudManager::Vm') AND "vms"."template" = $2 AND (((("vms"."id" IN (SELECT "vms"."id" FROM "vms"
INNER JOIN "taggings"
ON "vms"."id" = "taggings"."taggable_id"
INNER JOIN "tags"
ON "taggings"."tag_id" = "tags"."id"
WHERE "tags"."name" = '/managed/environment/prod' )) OR ("vms"."id" IN (SELECT "vms"."id" FROM "vms"
INNER JOIN "taggings"
ON "vms"."id" = "taggings"."taggable_id"
INNER JOIN "tags"
ON "taggings"."tag_id" = "tags"."id"
WHERE "tags"."name" = '/managed/environment/prod' ))) AND ("vms"."name" ILIKE 'bronagh%'))) [["taggable_type", "VmOrTemplate"], ["template", "f"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment