Katello 4.9 is very slow

I don’t think the number of lines of katello_repository_rpms is really the issue.
On our main katello instance we have 29 Content Views but only 2 versions each and we have

foreman=#  select count(*) from katello_repository_rpms;
  count
---------
 2756444
(1 row)

On another katello we have “only” 17 CV but each has 5 versions, so we have:

foreman=# select count(*) from katello_repository_rpms;
  count
---------
 3731712
(1 row)

which is about 1M more.

We updated both instances to katello 4.9 (and foreman 3.7) last weekend and both became very slow.
Yesterday we reverted the snapshot of the secondary one and upgraded it from 4.8.1 to 4.8.2 and it is working as fast as it was before.

So there is really an issue with foreman/katello 3.7/4.9 versions.

Is there anything I can test and/or try to debug this issue?
Thank you.