bkr/server/controllers.py has this code: 666 options['reprovision_distro_tree_id'] = [(dt.id, unicode(dt)) for dt in 667 system.distro_trees().order_by(Distro.name, 668 DistroTree.variant, DistroTree.arch_id)] which produces this slow query: Count: 15673 Time=0.14s (2259s) Lock=0.00s (2s) Rows_sent=353.3 (5537714), Rows_examined=40911.1 (641199732), beaker[beaker]@localhost SELECT osmajor.id AS osmajor_id, osmajor.osmajor AS osmajor_osmajor, osmajor.alias AS osmajor_alias, osversion.id AS osversion_id, osversion.osmajor_id AS osversion_osmajor_id, osversion.osminor AS osversion_osminor, distro.id AS distro_id, distro.name AS distro_name, distro.osversion_id AS distro_osversion_id, distro.date_created AS distro_date_created, distro_tree.id AS distro_tree_id, distro_tree.distro_id AS distro_tree_distro_id, distro_tree.arch_id AS distro_tree_arch_id, distro_tree.variant AS distro_tree_variant, distro_tree.ks_meta AS distro_tree_ks_meta, distro_tree.kernel_options AS distro_tree_kernel_options, distro_tree.kernel_options_post AS distro_tree_kernel_options_post, distro_tree.date_created AS distro_tree_date_created FROM distro_tree INNER JOIN distro ON distro.id = distro_tree.distro_id INNER JOIN osversion ON osversion.id = distro.osversion_id INNER JOIN osmajor ON osmajor.id = osversion.osmajor_id WHERE (EXISTS (SELECT N FROM distro_tree_lab_controller_map WHERE distro_tree.id = distro_tree_lab_controller_map.distro_tree_id AND N = distro_tree_lab_controller_map.lab_controller_id)) AND distro_tree.arch_id IN (N) AND NOT (EXISTS (SELECT N FROM exclude_osmajor WHERE osmajor.id = exclude_osmajor.osmajor_id AND N = exclude_osmajor.system_id AND exclude_osmajor.arch_id = distro_tree.arch_id)) AND NOT (EXISTS (SELECT N FROM exclude_osversion WHERE osversion.id = exclude_osversion.osversion_id AND N = exclude_osversion.system_id AND exclude_osversion.arch_id = distro_tree.arch_id)) ORDER BY distro.name, distro_tree.variant, distro_tree.arch_id but I'm 90% sure that code for reprovision_distro_tree_id is actually dead, since the UI is using the new distro tree selector modal now instead. Double check and then delete it to avoid these (relatively expensive!) pointless queries.
We know that the database is generally slow, having a ticket for each slow part of the database is not really useful. We will fix it together with other DB issues. Epic has been created for this type of issues.