Issue Summary
A count of all archived issues in active projects is automatically run when loading the archived issue page even before a search is run. No issues, counts, or other information is displayed on the page when this query is executed.
Steps to Reproduce
- Enable SQL logging
- Load the Archived Issues page (secure/BrowseArchivedIssues!default.jspa)
- Check for count query in logs
- It's important to note that the count is cached(appears to be for 30 minutes). The query can be triggered again if you archive a new issue and then refresh the page
- No results or count are displayed on the page at this point
Expected Results
We'd expect that a query is not run until a search/filter is submitted. Depending on the filter, it may not be necessary to go through all active projects
Actual Results
A count of all archived issues is automatically run for every active project:
2020-09-16 16:15:19,075 http-nio-8851-exec-3 xxx 975x2634x1 pzyc10 /secure/BrowseArchivedIssues!default.jspa 22ms "SELECT COUNT(I.ID) FROM public.jiraissue I WHERE (I.PROJECT IN ('10001', '10000') ) AND (I.ARCHIVED = 'Y' )"
2020-09-16 16:15:19,076 http-nio-8851-exec-3 xxx 975x2634x1 pzyc10 /secure/BrowseArchivedIssues!default.jspa 0ms "SELECT COUNT(I.ID) FROM public.jiraissue I WHERE I.ARCHIVED='Y'"
In the test case there are only two active projects. In larger instances though, this will be a much larger query.
Because of this the Archived Issues page can take a long time to load in larger environments.
Workaround
Add the following index to Jira's database:
create index on jiraissue (project,archived)
This will increase the query speed time from minutes to seconds and allow the Archived Issues page to load quickly