Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1517255 - slow query with big ReX jobs: SELECT COUNT(DISTINCT "hosts"."id") FROM ...
Summary: slow query with big ReX jobs: SELECT COUNT(DISTINCT "hosts"."id") FROM ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Search
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: 6.4.0
Assignee: Tomer Brisker
QA Contact: Jan Hutař
URL:
Whiteboard: scale_lab
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-24 11:55 UTC by Jan Hutař
Modified: 2019-11-05 23:10 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 19:10:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 20667 0 None None None 2017-11-28 21:22:22 UTC

Description Jan Hutař 2017-11-24 11:55:05 UTC
Description of problem:
There is a slow query (taking more than 1s:

2017-11-24 06:08:29 EST LOG:  duration: 1278.527 ms  execute a241: SELECT COUNT(DISTINCT "hosts"."id") FROM "hosts" LEFT OUTER JOIN "models" ON "models"."id" = "hosts"."model_id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" AND (hostgroups.id IN (1)) LEFT OUTER JOIN "nics" ON "nics"."host_id" = "hosts"."id" AND "nics"."primary" = $1 LEFT OUTER JOIN "domains" ON "domains"."id" = "nics"."domain_id" AND (domains.id IN (2)) LEFT OUTER JOIN "realms" ON "realms"."id" = "hosts"."realm_id" AND (1=0) LEFT OUTER JOIN "environments" ON "environments"."id" = "hosts"."environment_id" AND (environments.id IN (2)) LEFT OUTER JOIN "architectures" ON "architectures"."id" = "hosts"."architecture_id" LEFT OUTER JOIN "compute_resources" ON "compute_resources"."id" = "hosts"."compute_resource_id" AND (1=0) LEFT OUTER JOIN "images" ON "images"."id" = "hosts"."image_id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "hosts"."operatingsystem_id" LEFT OUTER JOIN "nics" "primary_interfaces_hosts" ON "primary_interfaces_hosts"."host_id" = "hosts"."id" AND "primary_interfaces_hosts"."primary" = $2 LEFT OUTER JOIN "nics" "interfaces_hosts" ON "interfaces_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "taxonomies" ON "taxonomies"."id" = "hosts"."location_id" AND "taxonomies"."type" IN ('Location') LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join" ON "primary_interfaces_hosts_join"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join"."primary" = $3 LEFT OUTER JOIN "subnets" ON "subnets"."id" = "primary_interfaces_hosts_join"."subnet_id" AND "subnets"."type" = $4 AND (1=0) LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join_2" ON "primary_interfaces_hosts_join_2"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join_2"."primary" = $5 LEFT OUTER JOIN "subnets" "subnet6s_hosts" ON "subnet6s_hosts"."id" = "primary_interfaces_hosts_join_2"."subnet6_id" AND "subnet6s_hosts"."type" = $6 AND (1=0) LEFT OUTER JOIN "nics" "provision_interfaces_hosts" ON "provision_interfaces_hosts"."host_id" = "hosts"."id" AND "provision_interfaces_hosts"."provision" = $7 LEFT OUTER JOIN "discovery_rules" ON "discovery_rules"."id" = "hosts"."discovery_rule_id" AND (1=0) LEFT OUTER JOIN "katello_host_collection_hosts" ON "katello_host_collection_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_host_collections" ON "katello_host_collections"."id" = "katello_host_collection_hosts"."host_collection_id" LEFT OUTER JOIN "katello_content_facets" ON "katello_content_facets"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_content_views" ON "katello_content_views"."id" = "katello_content_facets"."content_view_id" LEFT OUTER JOIN "katello_content_facets" "content_facets_hosts_join" ON "content_facets_hosts_join"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_environments" ON "katello_environments"."id" = "content_facets_hosts_join"."lifecycle_environment_id" LEFT OUTER JOIN "katello_content_facets" "content_facets_hosts_join_2" ON "content_facets_hosts_join_2"."host_id" = "hosts"."id" LEFT OUTER JOIN "smart_proxies" ON "smart_proxies"."id" = "content_facets_hosts_join_2"."content_source_id" AND (smart_proxies.id IN (1,8,6,2,3,4,5,7,9,10,11)) LEFT OUTER JOIN "katello_subscription_facets" ON "katello_subscription_facets"."host_id" = "hosts"."id" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 1 AND (("hosts"."name" ILIKE '%container100%' OR "hosts"."comment" ILIKE '%container100%' OR "models"."name" ILIKE '%container100%' OR "hostgroups"."name" ILIKE '%container100%' OR "hostgroups"."title" ILIKE '%container100%' OR "hostgroups"."title" ILIKE '%container100%' OR "domains"."name" ILIKE '%container100%' OR "realms"."name" ILIKE '%container100%' OR "environments"."name" ILIKE '%container100%' OR "architectures"."name" ILIKE '%container100%' OR "compute_resources"."name" ILIKE '%container100%' OR "images"."name" ILIKE '%container100%' OR "operatingsystems"."name" ILIKE '%container100%' OR "operatingsystems"."description" ILIKE '%container100%' OR "operatingsystems"."title" ILIKE '%container100%' OR "operatingsystems"."major" ILIKE '%container100%' OR "operatingsystems"."minor" ILIKE '%container100%' OR "nics"."ip" ILIKE '%container100%' OR "nics"."ip" ILIKE '%container100%' OR "nics"."mac" ILIKE '%container100%' OR "taxonomies"."title" ILIKE '%container100%' OR "subnets"."network" ILIKE '%container100%' OR "subnets"."name" ILIKE '%container100%' OR "subnets"."network" ILIKE '%container100%' OR "subnets"."name" ILIKE '%container100%' OR "hosts"."uuid" ILIKE '%container100%' OR "nics"."mac" ILIKE '%container100%' OR "operatingsystems"."name" ILIKE '%container100%' OR "operatingsystems"."description" ILIKE '%container100%' OR "operatingsystems"."title" ILIKE '%container100%' OR "operatingsystems"."major" ILIKE '%container100%' OR "operatingsystems"."minor" ILIKE '%container100%' OR "discovery_rules"."name" ILIKE '%container100%' OR "katello_host_collections"."name" ILIKE '%container100%' OR "katello_content_views"."name" ILIKE '%container100%' OR "katello_environments"."name" ILIKE '%container100%' OR "smart_proxies"."name" ILIKE '%container100%' OR "katello_subscription_facets"."release_version" ILIKE '%container100%' OR "katello_subscription_facets"."service_level" ILIKE '%container100%' OR "katello_subscription_facets"."registered_through" ILIKE '%container100%' OR "katello_subscription_facets"."uuid" ILIKE '%container100%' OR 1=0 OR 1=0 OR 1=0))
2017-11-24 06:08:29 EST DETAIL:  parameters: $1 = 't', $2 = 't', $3 = 't', $4 = 'Subnet::Ipv4', $5 = 't', $6 = 'Subnet::Ipv6', $7 = 't'


Version-Release number of selected component (if applicable):
satellite-6.3.0-21.0.beta.el7sat.noarch


How reproducible:
always


Steps to Reproduce:
1. Run ReX on subset of your 30k subscribed hosts and specify that subset with search query just "container1000" (it is part of the hostname, matching 29 hosts in my case)


Actual results:
There is a query taking above 1 second (add "log_min_duration_statement = 1000" to /var/lib/pgsql/data/postgresql.conf and restart/reload to make PostgreSQL to log it)


Expected results:
Maybe there is a way how to optimize the query?

Comment 1 Jan Hutař 2017-11-24 12:00:21 UTC
foreman=# EXPLAIN ANALYZE SELECT COUNT(DISTINCT "hosts"."id") FROM "hosts" LEFT OUTER JOIN "models" ON "models"."id" = "hosts"."model_id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" AND (hostgroups.id IN (1)) LEFT OUTER JOIN "nics" ON "nics"."host_id" = "hosts"."id" AND "nics"."primary" = 't' LEFT OUTER JOIN "domains" ON "domains"."id" = "nics"."domain_id" AND (domains.id IN (2)) LEFT OUTER JOIN "realms" ON "realms"."id" = "hosts"."realm_id" AND (1=0) LEFT OUTER JOIN "environments" ON "environments"."id" = "hosts"."environment_id" AND (environments.id IN (2)) LEFT OUTER JOIN "architectures" ON "architectures"."id" = "hosts"."architecture_id" LEFT OUTER JOIN "compute_resources" ON "compute_resources"."id" = "hosts"."compute_resource_id" AND (1=0) LEFT OUTER JOIN "images" ON "images"."id" = "hosts"."image_id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "hosts"."operatingsystem_id" LEFT OUTER JOIN "nics" "primary_interfaces_hosts" ON "primary_interfaces_hosts"."host_id" = "hosts"."id" AND "primary_interfaces_hosts"."primary" = 't' LEFT OUTER JOIN "nics" "interfaces_hosts" ON "interfaces_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "taxonomies" ON "taxonomies"."id" = "hosts"."location_id" AND "taxonomies"."type" IN ('Location') LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join" ON "primary_interfaces_hosts_join"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join"."primary" = 't' LEFT OUTER JOIN "subnets" ON "subnets"."id" = "primary_interfaces_hosts_join"."subnet_id" AND "subnets"."type" = 'Subnet::Ipv4' AND (1=0) LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join_2" ON "primary_interfaces_hosts_join_2"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join_2"."primary" = 't' LEFT OUTER JOIN "subnets" "subnet6s_hosts" ON "subnet6s_hosts"."id" = "primary_interfaces_hosts_join_2"."subnet6_id" AND "subnet6s_hosts"."type" = 'Subnet::Ipv6' AND (1=0) LEFT OUTER JOIN "nics" "provision_interfaces_hosts" ON "provision_interfaces_hosts"."host_id" = "hosts"."id" AND "provision_interfaces_hosts"."provision" = 't' LEFT OUTER JOIN "discovery_rules" ON "discovery_rules"."id" = "hosts"."discovery_rule_id" AND (1=0) LEFT OUTER JOIN "katello_host_collection_hosts" ON "katello_host_collection_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_host_collections" ON "katello_host_collections"."id" = "katello_host_collection_hosts"."host_collection_id" LEFT OUTER JOIN "katello_content_facets" ON "katello_content_facets"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_content_views" ON "katello_content_views"."id" = "katello_content_facets"."content_view_id" LEFT OUTER JOIN "katello_content_facets" "content_facets_hosts_join" ON "content_facets_hosts_join"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_environments" ON "katello_environments"."id" = "content_facets_hosts_join"."lifecycle_environment_id" LEFT OUTER JOIN "katello_content_facets" "content_facets_hosts_join_2" ON "content_facets_hosts_join_2"."host_id" = "hosts"."id" LEFT OUTER JOIN "smart_proxies" ON "smart_proxies"."id" = "content_facets_hosts_join_2"."content_source_id" AND (smart_proxies.id IN (1,8,6,2,3,4,5,7,9,10,11)) LEFT OUTER JOIN "katello_subscription_facets" ON "katello_subscription_facets"."host_id" = "hosts"."id" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 1 AND (("hosts"."name" ILIKE '%container100%' OR "hosts"."comment" ILIKE '%container100%' OR "models"."name" ILIKE '%container100%' OR "hostgroups"."name" ILIKE '%container100%' OR "hostgroups"."title" ILIKE '%container100%' OR "hostgroups"."title" ILIKE '%container100%' OR "domains"."name" ILIKE '%container100%' OR "realms"."name" ILIKE '%container100%' OR "environments"."name" ILIKE '%container100%' OR "architectures"."name" ILIKE '%container100%' OR "compute_resources"."name" ILIKE '%container100%' OR "images"."name" ILIKE '%container100%' OR "operatingsystems"."name" ILIKE '%container100%' OR "operatingsystems"."description" ILIKE '%container100%' OR "operatingsystems"."title" ILIKE '%container100%' OR "operatingsystems"."major" ILIKE '%container100%' OR "operatingsystems"."minor" ILIKE '%container100%' OR "nics"."ip" ILIKE '%container100%' OR "nics"."ip" ILIKE '%container100%' OR "nics"."mac" ILIKE '%container100%' OR "taxonomies"."title" ILIKE '%container100%' OR "subnets"."network" ILIKE '%container100%' OR "subnets"."name" ILIKE '%container100%' OR "subnets"."network" ILIKE '%container100%' OR "subnets"."name" ILIKE '%container100%' OR "hosts"."uuid" ILIKE '%container100%' OR "nics"."mac" ILIKE '%container100%' OR "operatingsystems"."name" ILIKE '%container100%' OR "operatingsystems"."description" ILIKE '%container100%' OR "operatingsystems"."title" ILIKE '%container100%' OR "operatingsystems"."major" ILIKE '%container100%' OR "operatingsystems"."minor" ILIKE '%container100%' OR "discovery_rules"."name" ILIKE '%container100%' OR "katello_host_collections"."name" ILIKE '%container100%' OR "katello_content_views"."name" ILIKE '%container100%' OR "katello_environments"."name" ILIKE '%container100%' OR "smart_proxies"."name" ILIKE '%container100%' OR "katello_subscription_facets"."release_version" ILIKE '%container100%' OR "katello_subscription_facets"."service_level" ILIKE '%container100%' OR "katello_subscription_facets"."registered_through" ILIKE '%container100%' OR "katello_subscription_facets"."uuid" ILIKE '%container100%' OR 1=0 OR 1=0 OR 1=0));
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                     QUERY PLAN                                                                                                                                                                                               
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
                                                                                     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
 Aggregate  (cost=41769.61..41769.62 rows=1 width=4) (actual time=1461.368..1461.368 rows=1 loops=1)
   ->  Hash Left Join  (cost=12596.15..41769.34 rows=108 width=4) (actual time=190.288..1461.258 rows=59 loops=1)
         Hash Cond: (content_facets_hosts_join_2.content_source_id = smart_proxies.id)
         Filter: (((hosts.name)::text ~~* '%container100%'::text) OR (hosts.comment ~~* '%container100%'::text) OR ((models.name)::text ~~* '%container100%'::text) OR ((hostgroups.name)::text ~~* '%container100%'::text) OR ((hostgroups.ti
tle)::text ~~* '%container100%'::text) OR ((hostgroups.title)::text ~~* '%container100%'::text) OR ((domains.name)::text ~~* '%container100%'::text) OR ((realms.name)::text ~~* '%container100%'::text) OR ((environments.name)::text ~~* '%c
ontainer100%'::text) OR ((architectures.name)::text ~~* '%container100%'::text) OR ((compute_resources.name)::text ~~* '%container100%'::text) OR ((images.name)::text ~~* '%container100%'::text) OR ((operatingsystems.name)::text ~~* '%con
tainer100%'::text) OR ((operatingsystems.description)::text ~~* '%container100%'::text) OR ((operatingsystems.title)::text ~~* '%container100%'::text) OR ((operatingsystems.major)::text ~~* '%container100%'::text) OR ((operatingsystems.mi
nor)::text ~~* '%container100%'::text) OR ((nics.ip)::text ~~* '%container100%'::text) OR ((nics.ip)::text ~~* '%container100%'::text) OR ((nics.mac)::text ~~* '%container100%'::text) OR ((taxonomies.title)::text ~~* '%container100%'::tex
t) OR ((subnets.network)::text ~~* '%container100%'::text) OR (subnets.name ~~* '%container100%'::text) OR ((subnets.network)::text ~~* '%container100%'::text) OR (subnets.name ~~* '%container100%'::text) OR ((hosts.uuid)::text ~~* '%cont
ainer100%'::text) OR ((nics.mac)::text ~~* '%container100%'::text) OR ((operatingsystems.name)::text ~~* '%container100%'::text) OR ((operatingsystems.description)::text ~~* '%container100%'::text) OR ((operatingsystems.title)::text ~~* '
%container100%'::text) OR ((operatingsystems.major)::text ~~* '%container100%'::text) OR ((operatingsystems.minor)::text ~~* '%container100%'::text) OR ((discovery_rules.name)::text ~~* '%container100%'::text) OR ((katello_host_collection
s.name)::text ~~* '%container100%'::text) OR ((katello_content_views.name)::text ~~* '%container100%'::text) OR ((katello_environments.name)::text ~~* '%container100%'::text) OR ((smart_proxies.name)::text ~~* '%container100%'::text) OR (
(katello_subscription_facets.release_version)::text ~~* '%container100%'::text) OR ((katello_subscription_facets.service_level)::text ~~* '%container100%'::text) OR ((katello_subscription_facets.registered_through)::text ~~* '%container10
0%'::text) OR ((katello_subscription_facets.uuid)::text ~~* '%container100%'::text))
         Rows Removed by Filter: 29863
         ->  Nested Loop Left Join  (cost=12585.06..41645.95 rows=29917 width=10221) (actual time=159.836..855.788 rows=29922 loops=1)
               ->  Hash Left Join  (cost=12585.06..29158.77 rows=29917 width=9611) (actual time=159.805..767.773 rows=29922 loops=1)
                     Hash Cond: (hosts.id = content_facets_hosts_join_2.host_id)
                     ->  Hash Left Join  (cost=11296.97..27243.41 rows=29917 width=9607) (actual time=144.848..708.358 rows=29922 loops=1)
                           Hash Cond: (content_facets_hosts_join.lifecycle_environment_id = katello_environments.id)
                           ->  Hash Left Join  (cost=11285.39..26820.48 rows=29917 width=9095) (actual time=144.822..694.533 rows=29922 loops=1)
                                 Hash Cond: (hosts.id = content_facets_hosts_join.host_id)
                                 ->  Hash Left Join  (cost=9997.29..24905.11 rows=29917 width=9091) (actual time=130.476..638.475 rows=29922 loops=1)
                                       Hash Cond: (katello_content_facets.content_view_id = katello_content_views.id)
                                       ->  Hash Left Join  (cost=9985.72..24482.18 rows=29917 width=8579) (actual time=130.451..625.465 rows=29922 loops=1)
                                             Hash Cond: (hosts.id = katello_content_facets.host_id)
                                             ->  Nested Loop Left Join  (cost=8697.62..22566.82 rows=29917 width=8575) (actual time=114.081..566.019 rows=29922 loops=1)
                                                   Join Filter: false
                                                   ->  Hash Left Join  (cost=8697.62..22566.82 rows=29917 width=8059) (actual time=114.077..550.930 rows=29922 loops=1)
                                                         Hash Cond: (hosts.id = provision_interfaces_hosts.host_id)
                                                         ->  Nested Loop Left Join  (cost=7272.94..20207.49 rows=29917 width=8059) (actual time=96.357..491.984 rows=29922 loops=1)
                                                               Join Filter: false
                                                               ->  Hash Left Join  (cost=7272.94..20207.49 rows=29917 width=8059) (actual time=96.355..477.389 rows=29922 loops=1)
                                                                     Hash Cond: (hosts.id = primary_interfaces_hosts_join_2.host_id)
                                                                     ->  Nested Loop Left Join  (cost=5848.26..17848.16 rows=29917 width=8059) (actual time=78.932..419.012 rows=29922 loops=1)
                                                                           Join Filter: false
                                                                           ->  Hash Left Join  (cost=5848.26..17848.16 rows=29917 width=7919) (actual time=78.929..402.393 rows=29922 loops=1)
                                                                                 Hash Cond: (hosts.id = katello_host_collection_hosts.host_id)
                                                                                 ->  Hash Left Join  (cost=5779.49..12455.12 rows=29917 width=7403) (actual time=78.912..391.221 rows=29922 loops=1)
                                                                                       Hash Cond: (hosts.id = primary_interfaces_hosts_join.host_id)
                                                                                       ->  Hash Left Join  (cost=4354.81..10095.79 rows=29917 width=7403) (actual time=60.512..332.049 rows=29922 loops=1)
                                                                                             Hash Cond: (hosts.location_id = taxonomies.id)
                                                                                             ->  Hash Left Join  (cost=4344.42..9963.25 rows=29917 width=6891) (actual time=60.460..318.791 rows=29922 loops=1)
                                                                                                   Hash Cond: (hosts.id = interfaces_hosts.host_id)
                                                                                                   ->  Hash Left Join  (cost=2919.60..7603.67 rows=29917 width=6891) (actual time=45.210..262.899 rows=29912 loops=1)
                                                                                                         Hash Cond: (hosts.id = primary_interfaces_hosts.host_id)
                                                                                                         ->  Hash Left Join  (cost=1494.92..5244.35 rows=29917 width=6891) (actual time=25.794..201.739 rows=29912 loops=1)
                                                                                                               Hash Cond: (hosts.operatingsystem_id = operatingsystems.id)
                                                                                                               ->  Hash Left Join  (cost=1484.47..4822.54 rows=29917 width=5273) (actual time=25.778..187.635 rows=29912 loops=1)
                                                                                                                     Hash Cond: (hosts.image_id = images.id)
                                                                                                                     ->  Nested Loop Left Join  (cost=1473.80..4699.67 rows=29917 width=4761) (actual time=25.760..177.751 rows=29912 loops=1)
                                                                                                                           Join Filter: false
                                                                                                                           ->  Hash Left Join  (cost=1473.80..4699.67 rows=29917 width=4245) (actual time=25.758..163.395 rows=29912 loops=1)
                                                                                                                                 Hash Cond: (hosts.architecture_id = architectures.id)
                                                                                                                                 ->  Hash Left Join  (cost=1460.65..4275.16 rows=29917 width=3733) (actual time=25.724..150.344 rows=29912 loo
ps=1)
                                                                                                                                       Hash Cond: (hosts.environment_id = environments.id)
                                                                                                                                       ->  Nested Loop Left Join  (cost=1452.37..4154.68 rows=29917 width=3221) (actual time=25.696..141.542 r
ows=29912 loops=1)
                                                                                                                                             Join Filter: false
                                                                                                                                             ->  Hash Left Join  (cost=1452.37..4154.68 rows=29917 width=2705) (actual time=25.689..128.071 ro
ws=29912 loops=1)
                                                                                                                                                   Hash Cond: (nics.domain_id = domains.id)
                                                                                                                                                   ->  Hash Left Join  (cost=1444.09..4029.94 rows=29917 width=2193) (actual time=25.653..115.
859 rows=29912 loops=1)
                                                                                                                                                         Hash Cond: (hosts.id = nics.host_id)
                                                                                                                                                         ->  Hash Left Join  (cost=19.41..1670.61 rows=29917 width=2157) (actual time=0.051..4
3.621 rows=29912 loops=1)
                                                                                                                                                               Hash Cond: (hosts.hostgroup_id = hostgroups.id)
                                                                                                                                                               ->  Hash Left Join  (cost=11.12..1535.19 rows=29917 width=1129) (actual time=0.
030..31.298 rows=29912 loops=1)
                                                                                                                                                                     Hash Cond: (hosts.model_id = models.id)
                                                                                                                                                                     ->  Seq Scan on hosts  (cost=0.00..1411.77 rows=29917 width=617) (actual 
time=0.014..22.364 rows=29912 loops=1)
                                                                                                                                                                           Filter: (((type)::text = 'Host::Managed'::text) AND (organization_i
d = 1))
                                                                                                                                                                           Rows Removed by Filter: 1
                                                                                                                                                                     ->  Hash  (cost=10.50..10.50 rows=50 width=520) (actual time=0.005..0.005
 rows=1 loops=1)
                                                                                                                                                                           Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                                                                           ->  Seq Scan on models  (cost=0.00..10.50 rows=50 width=520) (actua
l time=0.003..0.004 rows=1 loops=1)
                                                                                                                                                               ->  Hash  (cost=8.27..8.27 rows=1 width=1036) (actual time=0.013..0.013 rows=1 
loops=1)
                                                                                                                                                                     Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                                                                     ->  Index Scan using hostgroups_pkey on hostgroups  (cost=0.00..8.27 rows
=1 width=1036) (actual time=0.012..0.013 rows=1 loops=1)
                                                                                                                                                                           Index Cond: (id = 1)
                                                                                                                                                         ->  Hash  (cost=1051.03..1051.03 rows=29892 width=40) (actual time=25.577..25.577 row
s=29913 loops=1)
                                                                                                                                                               Buckets: 4096  Batches: 1  Memory Usage: 2109kB
                                                                                                                                                               ->  Seq Scan on nics  (cost=0.00..1051.03 rows=29892 width=40) (actual time=0.0
02..16.777 rows=29913 loops=1)
                                                                                                                                                                     Filter: "primary"
                                                                                                                                                                     Rows Removed by Filter: 11
                                                                                                                                                   ->  Hash  (cost=8.27..8.27 rows=1 width=520) (actual time=0.016..0.016 rows=1 loops=1)
                                                                                                                                                         Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                                                         ->  Index Scan using domains_pkey on domains  (cost=0.00..8.27 rows=1 width=520) (act
ual time=0.013..0.013 rows=1 loops=1)
                                                                                                                                                               Index Cond: (id = 2)
                                                                                                                                             ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=29912)
                                                                                                                                                   One-Time Filter: false
                                                                                                                                       ->  Hash  (cost=8.27..8.27 rows=1 width=520) (actual time=0.017..0.017 rows=1 loops=1)
                                                                                                                                             Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                                             ->  Index Scan using environments_pkey on environments  (cost=0.00..8.27 rows=1 width=520) (actua
l time=0.014..0.015 rows=1 loops=1)
                                                                                                                                                   Index Cond: (id = 2)
                                                                                                                                 ->  Hash  (cost=11.40..11.40 rows=140 width=520) (actual time=0.005..0.005 rows=2 loops=1)
                                                                                                                                       Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                                       ->  Seq Scan on architectures  (cost=0.00..11.40 rows=140 width=520) (actual time=0.003..0.003 rows=2 l
oops=1)
                                                                                                                           ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=29912)
                                                                                                                                 One-Time Filter: false
                                                                                                                     ->  Hash  (cost=10.30..10.30 rows=30 width=520) (actual time=0.001..0.001 rows=0 loops=1)
                                                                                                                           Buckets: 1024  Batches: 1  Memory Usage: 0kB
                                                                                                                           ->  Seq Scan on images  (cost=0.00..10.30 rows=30 width=520) (actual time=0.000..0.000 rows=0 loops=1)
                                                                                                               ->  Hash  (cost=10.20..10.20 rows=20 width=1626) (actual time=0.006..0.006 rows=1 loops=1)
                                                                                                                     Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                                                                                                     ->  Seq Scan on operatingsystems  (cost=0.00..10.20 rows=20 width=1626) (actual time=0.003..0.004 rows=1 loops=1)
                                                                                                         ->  Hash  (cost=1051.03..1051.03 rows=29892 width=4) (actual time=19.391..19.391 rows=29913 loops=1)
                                                                                                               Buckets: 4096  Batches: 1  Memory Usage: 1052kB
                                                                                                               ->  Seq Scan on nics primary_interfaces_hosts  (cost=0.00..1051.03 rows=29892 width=4) (actual time=0.003..12.609 rows=29913 lo
ops=1)
                                                                                                                     Filter: "primary"
                                                                                                                     Rows Removed by Filter: 11
                                                                                                   ->  Hash  (cost=1051.03..1051.03 rows=29903 width=4) (actual time=15.221..15.221 rows=29924 loops=1)
                                                                                                         Buckets: 4096  Batches: 1  Memory Usage: 1053kB
                                                                                                         ->  Seq Scan on nics interfaces_hosts  (cost=0.00..1051.03 rows=29903 width=4) (actual time=0.003..8.801 rows=29924 loops=1)
                                                                                             ->  Hash  (cost=10.38..10.38 rows=1 width=520) (actual time=0.023..0.023 rows=11 loops=1)
                                                                                                   Buckets: 1024  Batches: 1  Memory Usage: 2kB
                                                                                                   ->  Seq Scan on taxonomies  (cost=0.00..10.38 rows=1 width=520) (actual time=0.010..0.017 rows=11 loops=1)
                                                                                                         Filter: ((type)::text = 'Location'::text)
                                                                                                         Rows Removed by Filter: 1
                                                                                       ->  Hash  (cost=1051.03..1051.03 rows=29892 width=4) (actual time=18.376..18.376 rows=29913 loops=1)
                                                                                             Buckets: 4096  Batches: 1  Memory Usage: 1052kB
                                                                                             ->  Seq Scan on nics primary_interfaces_hosts_join  (cost=0.00..1051.03 rows=29892 width=4) (actual time=0.004..11.814 rows=29913 loops=1)
                                                                                                   Filter: "primary"
                                                                                                   Rows Removed by Filter: 11
                                                                                 ->  Hash  (cost=51.28..51.28 rows=1400 width=520) (actual time=0.002..0.002 rows=0 loops=1)
                                                                                       Buckets: 1024  Batches: 1  Memory Usage: 0kB
                                                                                       ->  Hash Left Join  (cost=12.93..51.28 rows=1400 width=520) (actual time=0.001..0.001 rows=0 loops=1)
                                                                                             Hash Cond: (katello_host_collection_hosts.host_collection_id = katello_host_collections.id)
                                                                                             ->  Seq Scan on katello_host_collection_hosts  (cost=0.00..24.00 rows=1400 width=8) (actual time=0.001..0.001 rows=0 loops=1)
                                                                                             ->  Hash  (cost=11.30..11.30 rows=130 width=520) (never executed)
                                                                                                   ->  Seq Scan on katello_host_collections  (cost=0.00..11.30 rows=130 width=520) (never executed)
                                                                           ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=29922)
                                                                                 One-Time Filter: false
                                                                     ->  Hash  (cost=1051.03..1051.03 rows=29892 width=4) (actual time=17.392..17.392 rows=29913 loops=1)
                                                                           Buckets: 4096  Batches: 1  Memory Usage: 1052kB
                                                                           ->  Seq Scan on nics primary_interfaces_hosts_join_2  (cost=0.00..1051.03 rows=29892 width=4) (actual time=0.003..11.069 rows=29913 loops=1)
                                                                                 Filter: "primary"
                                                                                 Rows Removed by Filter: 11
                                                               ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=29922)
                                                                     One-Time Filter: false
                                                         ->  Hash  (cost=1051.03..1051.03 rows=29892 width=4) (actual time=17.683..17.683 rows=29913 loops=1)
                                                               Buckets: 4096  Batches: 1  Memory Usage: 1052kB
                                                               ->  Seq Scan on nics provision_interfaces_hosts  (cost=0.00..1051.03 rows=29892 width=4) (actual time=0.003..11.363 rows=29913 loops=1)
                                                                     Filter: provision
                                                                     Rows Removed by Filter: 11
                                                   ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=29922)
                                                         One-Time Filter: false
                                             ->  Hash  (cost=924.71..924.71 rows=29071 width=8) (actual time=16.335..16.335 rows=29912 loops=1)
                                                   Buckets: 4096  Batches: 1  Memory Usage: 1169kB
                                                   ->  Seq Scan on katello_content_facets  (cost=0.00..924.71 rows=29071 width=8) (actual time=0.004..9.949 rows=29912 loops=1)
                                       ->  Hash  (cost=10.70..10.70 rows=70 width=520) (actual time=0.007..0.007 rows=2 loops=1)
                                             Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                             ->  Seq Scan on katello_content_views  (cost=0.00..10.70 rows=70 width=520) (actual time=0.005..0.005 rows=2 loops=1)
                                 ->  Hash  (cost=924.71..924.71 rows=29071 width=8) (actual time=14.321..14.321 rows=29912 loops=1)
                                       Buckets: 4096  Batches: 1  Memory Usage: 1169kB
                                       ->  Seq Scan on katello_content_facets content_facets_hosts_join  (cost=0.00..924.71 rows=29071 width=8) (actual time=0.014..7.592 rows=29912 loops=1)
                           ->  Hash  (cost=10.70..10.70 rows=70 width=520) (actual time=0.007..0.007 rows=1 loops=1)
                                 Buckets: 1024  Batches: 1  Memory Usage: 1kB
                                 ->  Seq Scan on katello_environments  (cost=0.00..10.70 rows=70 width=520) (actual time=0.006..0.006 rows=1 loops=1)
                     ->  Hash  (cost=924.71..924.71 rows=29071 width=8) (actual time=14.924..14.924 rows=29912 loops=1)
                           Buckets: 4096  Batches: 1  Memory Usage: 1052kB
                           ->  Seq Scan on katello_content_facets content_facets_hosts_join_2  (cost=0.00..924.71 rows=29071 width=8) (actual time=0.003..8.054 rows=29912 loops=1)
               ->  Index Scan using katello_subscription_facets_host_id on katello_subscription_facets  (cost=0.00..0.41 rows=1 width=614) (actual time=0.002..0.002 rows=1 loops=29922)
                     Index Cond: (host_id = hosts.id)
         ->  Hash  (cost=10.95..10.95 rows=11 width=520) (actual time=0.024..0.024 rows=11 loops=1)
               Buckets: 1024  Batches: 1  Memory Usage: 1kB
               ->  Seq Scan on smart_proxies  (cost=0.00..10.95 rows=11 width=520) (actual time=0.010..0.019 rows=11 loops=1)
                     Filter: (id = ANY ('{1,8,6,2,3,4,5,7,9,10,11}'::integer[]))
 Total runtime: 1463.999 ms
(155 rows)

Comment 2 Adam Ruzicka 2017-11-24 12:14:16 UTC
Note:
When you don't specify a key to search by, scoped search tries to search for anything matching the value in all columns and defined searches. This leads to massive queries like this.

Comment 3 Jan Hutař 2017-11-24 13:37:31 UTC
Yes, I agree this bug is questionable.

Comment 4 Tomer Brisker 2017-11-28 21:22:19 UTC
Connecting redmine issue http://projects.theforeman.org/issues/20667 from this bug

Comment 6 Satellite Program 2017-11-29 09:25:21 UTC
Upstream bug assigned to tbrisker

Comment 7 Satellite Program 2017-11-29 09:25:26 UTC
Upstream bug assigned to tbrisker

Comment 9 Satellite Program 2017-12-18 13:25:12 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20667 has been resolved.

Comment 12 Bryan Kearney 2018-10-16 19:10:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927


Note You need to log in before you can comment on or make changes to this bug.