Just to add here. I have seen the slow list since 4.9. I have just upgraded to 4.10.
The url https://foreman8.example.com/katello/api/v2/content_views?organization_id=1&nondefault=true&include_permissions=true&sort_by=name&sort_order=asc&per_page=20&page=1
takes approx 26s to load. It’s pretty steady.
I only have 11 content views, no composite views, 6 have filters, 5 have no filters. 274 hosts.
I have checked for queries longer than 100ms but nothing:
2024-01-19 07:29:51 CET LOG: parameter "log_min_duration_statement" changed to "100"
2024-01-19 07:30:37 CET LOG: duration: 1002.752 ms statement: select pg_sleep(1);
I have just stopped my external proxies and stop foreman-proxy.service and puppetserver.service on the main server which reduced pretty much of the background noise. I have set log_statement to all in postgresql.conf. Load the api url, which again took 26s and grep the logs for the timeframe like this:
$ grep SELECT p.log | sed -e 's/^.*statement: //' -e 's/^.*execute [^ ]*: //' | grep -v -e 'core_taskschedule' -e core_worker -e pg_try_advisory_lock -e pg_advisory_unlock -e dynflow_ -e taxonomies -e auditable_type -e core_contentappstatus -e foreman_tasks_tasks | sort -d | uniq -c | sort -n
which got me this list of queries run:
1 SELECT "katello_activation_keys".* FROM "katello_activation_keys" WHERE "katello_activation_keys"."content_view_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
1 SELECT "katello_content_view_environments".* FROM "katello_content_view_environments" WHERE "katello_content_view_environments"."content_view_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
1 SELECT "katello_content_view_repositories".* FROM "katello_content_view_repositories" WHERE "katello_content_view_repositories"."content_view_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
1 SELECT "katello_content_view_versions".* FROM "katello_content_view_versions" WHERE "katello_content_view_versions"."content_view_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
1 SELECT "katello_content_views".* FROM "katello_content_views" WHERE "katello_content_views"."id" IN (SELECT DISTINCT "katello_content_views"."id" FROM "katello_content_views" WHERE "katello_content_views"."generated_for" NOT IN ($1, $2, $3, $4) AND "katello_content_views"."organization_id" = $5 AND "katello_content_views"."default" = $6) ORDER BY "katello_content_views"."name" ASC NULLS FIRST , katello_content_views.id DESC LIMIT $7 OFFSET $8
1 SELECT "katello_environments".* FROM "katello_environments" WHERE "katello_environments"."id" IN ($1, $2, $3)
1 SELECT "katello_repositories".* FROM "katello_repositories" WHERE "katello_repositories"."id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $100, $101, $102, $103, $104, $105, $106, $107, $108, $109, $110, $111, $112, $113, $114, $115, $116, $117, $118, $119, $120, $121, $122, $123, $124, $125, $126, $127, $128, $129, $130, $131, $132, $133, $134, $135, $136, $137, $138, $139, $140, $141, $142, $143, $144, $145, $146, $147, $148, $149, $150, $151, $152, $153, $154, $155, $156, $157, $158, $159, $160, $161)
1 SELECT "sessions".* FROM "sessions" WHERE "sessions"."session_id" = $1 ORDER BY "sessions"."id" ASC LIMIT $2
1 SELECT "settings".* FROM "settings" WHERE (updated_at >= '2024-01-16 06:17:42.619533')
1 SELECT COUNT(*) FROM "katello_content_views" WHERE "katello_content_views"."id" IN (SELECT DISTINCT "katello_content_views"."id" FROM "katello_content_views" WHERE "katello_content_views"."generated_for" NOT IN ($1, $2, $3, $4) AND "katello_content_views"."organization_id" = $5 AND "katello_content_views"."default" = $6)
1 SELECT COUNT(*) FROM "katello_environments"
1 SELECT COUNT(DISTINCT "katello_content_views"."id") FROM "katello_content_views" WHERE "katello_content_views"."generated_for" NOT IN ($1, $2, $3, $4) AND "katello_content_views"."organization_id" = $5 AND "katello_content_views"."default" = $6
2 SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME, PRIORITY FROM QRTZ_TRIGGERS WHERE SCHED_NAME = 'QuartzScheduler' AND TRIGGER_STATE = $1 AND NEXT_FIRE_TIME <= $2 AND (MISFIRE_INSTR = -1 OR (MISFIRE_INSTR != -1 AND NEXT_FIRE_TIME >= $3)) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC
3 SELECT "settings".* FROM "settings" WHERE (updated_at >= '2024-01-16 06:19:04.232826')
4 SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = $1 LIMIT $2
4 SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2
14 SELECT "katello_events".* FROM "katello_events" WHERE ("katello_events"."process_after" IS NULL OR "katello_events"."process_after" BETWEEN $1 AND $2) AND "katello_events"."in_progress" = $3 ORDER BY "katello_events"."created_at" ASC LIMIT $4
18 SELECT "katello_content_view_components".* FROM "katello_content_view_components" WHERE "katello_content_view_components"."composite_content_view_id" = $1
18 SELECT "katello_content_view_components".* FROM "katello_content_view_components" WHERE "katello_content_view_components"."content_view_id" = $1
18 SELECT "katello_content_view_versions".* FROM "katello_content_view_versions" WHERE "katello_content_view_versions"."content_view_id" = $1 ORDER BY "katello_content_view_versions"."created_at" DESC LIMIT $2
18 SELECT "katello_content_view_versions".* FROM "katello_content_view_versions" WHERE "katello_content_view_versions"."content_view_id" = $1 ORDER BY major DESC, minor DESC LIMIT $2
18 SELECT "katello_environments".* FROM "katello_environments" INNER JOIN "katello_content_view_environments" ON "katello_environments"."id" = "katello_content_view_environments"."environment_id" WHERE "katello_content_view_environments"."content_view_version_id" = $1
18 SELECT 1
18 SELECT COUNT(*) FROM "katello_content_view_versions" WHERE "katello_content_view_versions"."content_view_id" = $1
19 SELECT "hosts".* FROM "hosts" INNER JOIN "katello_content_facets" ON "hosts"."id" = "katello_content_facets"."host_id" INNER JOIN "katello_content_view_environment_content_facets" ON "katello_content_facets"."id" = "katello_content_view_environment_content_facets"."content_facet_id" INNER JOIN "katello_content_view_environments" ON "katello_content_view_environment_content_facets"."content_view_environment_id" = "katello_content_view_environments"."id" WHERE "hosts"."organization_id" = $1 AND "hosts"."location_id" = $2 AND "hosts"."type" = $3 AND "katello_content_view_environments"."content_view_id" = $4
19 SELECT "katello_content_view_filters".* FROM "katello_content_view_filters" WHERE "katello_content_view_filters"."content_view_id" = $1
19 SELECT "katello_content_view_histories".* FROM "katello_content_view_histories" INNER JOIN "katello_content_view_versions" ON "katello_content_view_versions"."id" = "katello_content_view_histories"."katello_content_view_version_id" WHERE "katello_content_view_versions"."content_view_id" = $1 ORDER BY "katello_content_view_histories"."created_at" DESC LIMIT $2
19 SELECT "katello_content_view_versions".* FROM "katello_content_view_versions" WHERE "katello_content_view_versions"."content_view_id" = $1 ORDER BY created_at DESC
54 SELECT "hosts"."id" FROM "hosts" INNER JOIN "katello_content_facets" ON "hosts"."id" = "katello_content_facets"."host_id" INNER JOIN "katello_content_view_environment_content_facets" ON "katello_content_facets"."id" = "katello_content_view_environment_content_facets"."content_facet_id" INNER JOIN "katello_content_view_environments" ON "katello_content_view_environment_content_facets"."content_view_environment_id" = "katello_content_view_environments"."id" INNER JOIN "katello_content_facets" "content_facets_hosts" ON "content_facets_hosts"."host_id" = "hosts"."id" INNER JOIN "katello_content_view_environment_content_facets" "content_view_environment_content_facets_katello_content_facets" ON "content_view_environment_content_facets_katello_content_facets"."content_facet_id" = "content_facets_hosts"."id" INNER JOIN "katello_content_view_environments" "content_view_environments_katello_content_view_environment_cont" ON "content_view_environments_katello_content_view_environment_cont"."id" = "content_view_environment_content_facets_katello_content_facets"."content_view_environment_id" WHERE "hosts"."organization_id" = $1 AND "hosts"."location_id" = $2 AND "hosts"."type" = $3 AND "katello_content_view_environments"."content_view_id" = $4 AND "katello_content_view_environments"."environment_id" = $5
54 SELECT "katello_activation_keys"."id" FROM "katello_activation_keys" WHERE "katello_activation_keys"."content_view_id" = $1 AND "katello_activation_keys"."environment_id" = $2
89 SELECT "katello_content_view_histories".* FROM "katello_content_view_histories" WHERE "katello_content_view_histories"."katello_content_view_version_id" = $1 AND "katello_content_view_histories"."action" = $2 ORDER BY "katello_content_view_histories"."id" ASC LIMIT $3
90 SELECT "katello_environments"."id" FROM "katello_environments" INNER JOIN "katello_content_view_environments" ON "katello_environments"."id" = "katello_content_view_environments"."environment_id" WHERE "katello_content_view_environments"."content_view_version_id" = $1
272 SELECT "katello_root_repositories".* FROM "katello_root_repositories" WHERE "katello_root_repositories"."id" = $1 LIMIT $2