Katello 4.9 is very slow

Are there any long-running foreman tasks in the system at the time of this long-running query? We can narrow down the source of this query from the task in question. I can think of something like a sync task doing this or orphan cleanup looking to delete rpms not in any repositories anymore.