Favourite Filters Issue Count Performance problems in large instances (Jira)

As described in this Atlassian ticket there may be performance problems using Favourite Filters gadget in large Jira instances.

In our Jira instance (>2m issues, >10k users) these favfilters?showCounts=true requests where very expensive to CPU load.

In Atlassian ticket there is workaround provided how to turn off this feature in proxy level, but what to do if no proxy is used in front of Jira?

In our case we used Tuckey UrlRewriteFilter which is built in Jira by default. Open /jira_install_dir/atlassian-jira/WEB-INF/urlrewrite.xml and add this code before closing </urlrewrite> tag:

<rule enabled="true">
    <name>Disables Favourite Filters Issue Count</name>
    <condition type="parameter" name="showCounts" operator="equal">true</condition>
    <from>^/rest/gadget/1.0/favfilters</from>
    <to type="permanent-redirect">/rest/gadget/1.0/favfilters?showCounts=false</to>
</rule>

After Jira restart users will see “UNDEFINED” result if they turn on Issue Count functionality.