Bug #33763
openAuthorization generates inefficient SQL query for taxonomy-overriden permissions
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1985101
Description of problem:
Job execution lookups prior to firing off a new job was suddenly very slow, taking upwards of 5 minutes to instantiate a single job execution.
After creating a new index on the foreman database, job execution instantiation went back to the usual duration of 3 seconds.
The index was created on the taxable_taxonomies table with the command below:
create unique index taxable_id_id on taxable_taxonomies (taxable_id, id);
Version-Release number of selected component (if applicable):
satellite-6.8.5-1.el7sat.noarch
How reproducible:
100% of times when invoking a new job.
Steps to Reproduce:
1. Invoke new job on the web UI or through hammer.
Actual results:
Takes upwards of 5 minutes to create the job.
Expected results:
Few seconds to create the job.
Additional info:
The new index was created after examining the SQL queries being run by foreman while invoking the job. The new DB index changed the job template lookup significantly: the sql query now avoids nested loops and does merge joins and hashed joins instead.