Actions
Bug #18893
closeddashboard widget for puppet report latest events can be very slow on large amount of reports
Description
I have about 3M reports, and I see
16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [I] Started GET "/widgets/19" for ::1 at 2017-03-14 16:02:11 +0200 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [I] Processing by DashboardController#show as HTML 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [I] Parameters: {"id"=>"19"} 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] ActiveRecord::SessionStore::Session Load (0.2ms) SELECT "sessions".* FROM "sessions" WHERE "sessions"."session_id" = $1 ORDER BY "sessions"."id" ASC LIMIT 1 [["session_id", "843d16a1d11fc12baad1b8281e4926d2"]] 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]] 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [D] Setting current user thread-local variable to admin 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] (0.3ms) SELECT COUNT(*) FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [D] Setting current organization thread-local variable to none 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] (0.3ms) SELECT COUNT(*) FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [app] [D] Setting current location thread-local variable to none 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] AuthSource Load (0.2ms) SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = $1 LIMIT 1 [["id", 1]] 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] (0.7ms) SELECT "taxonomies"."id" FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') LIMIT 1 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] (0.3ms) SELECT "taxonomies"."id" FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') LIMIT 1 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] (0.4ms) SELECT COUNT(*) FROM "widgets" 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] Widget Load (0.4ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."id" = $1 LIMIT 1 [["id", 19]] 16:02:11 rails.1 | 2017-03-14T16:02:11 843d16a1 [sql] [D] User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY firstname LIMIT 1 [["id", 1]] 16:04:21 rails.1 | 2017-03-14T16:04:21 843d16a1 [sql] [D] ConfigReport Exists (129783.2ms) SELECT 1 AS one FROM "reports" WHERE "reports"."type" IN ('ConfigReport') AND (status <> 0) AND ("reports"."host_id" IN (SELECT "hosts"."id" FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed'))) AND (("reports"."reported_at" >= '2017-03-08')) LIMIT 1 16:04:21 rails.1 | 2017-03-14T16:04:21 843d16a1 [app] [I] Rendered dashboard/_reports_widget.html.erb (129789.7ms) 16:04:21 rails.1 | 2017-03-14T16:04:21 843d16a1 [app] [I] Completed 200 OK in 129811ms (Views: 10.1ms | ActiveRecord: 129786.7ms) 16:04:21 rails.1 | 2017-03-14T16:04:21 843d16a1 [sql] [D] (4.2ms) BEGIN 16:04:21 rails.1 | 2017-03-14T16:04:21 843d16a1 [sql] [D] (0.2ms) COMMIT
I believe this happens because we join the reports and hosts table where I'm uncertain its required.
Actions