Get better performance for the History list per harvestid in the GUI

Description

Message et fix from Tue:

I found out that the current indexes is not used by our code in HarvestDefinitionDBDAO in the method getHarvestRunInfo().
If somebody add “and jobs.harvest_id = historyinfo.harvest_id” to each where clause, you get immediate response for the selects instead of 30 secs or more!

Here are the 2 different queries:

s = c.prepareStatement("SELECT name, harvest_num, status, MIN(startdate), MAX(enddate), COUNT(job_id)"
+ " FROM jobs, harvestdefinitions"
+ " WHERE harvestdefinitions.harvest_id = ? AND jobs.harvest_id = harvestdefinitions.harvest_id"
+ " GROUP BY name, harvest_num, status ORDER BY harvest_num DESC");
and
s = c.prepareStatement("SELECT jobs.harvest_num, SUM(historyinfo.bytecount), "
+ "SUM(historyinfo.objectcount)," + "COUNT(jobs.status)" + " FROM jobs, historyinfo "
+ " WHERE jobs.harvest_id = ? AND historyinfo.job_id = jobs.job_id" + " GROUP BY jobs.harvest_num"
+ " ORDER BY jobs.harvest_num");

I have verified the where clause changes by following example in our jobs database:

prod_harvestdb=# SELECT jobs.harvest_num, SUM(historyinfo.bytecount), SUM(historyinfo.objectcount),COUNT(jobs.status) FROM jobs, historyinfo WHERE jobs.harvest_id = 370 AND historyinfo.job_id = jobs.job_id GROUP BY jobs.harvest_num ORDER BY jobs.harvest_num;

prod_harvestdb=# SELECT jobs.harvest_num, SUM(historyinfo.bytecount), SUM(historyinfo.objectcount),COUNT(jobs.status) FROM jobs, historyinfo WHERE jobs.harvest_id = 370 AND historyinfo.job_id = jobs.job_id and jobs.harvest_id = historyinfo.harvest_id GROUP BY jobs.harvest_num ORDER BY jobs.harvest_num;

Hopefully somebody can add that change to the code….

 

Checklist

Activity

Show:
Fixed

Details

Assignee

Reporter

Organization

SB/KB

Inspector (migrated)

Components

Fix versions

Affects versions

Priority

Checklist

Created July 5, 2022 at 12:45 PM
Updated August 8, 2022 at 2:07 PM
Resolved July 15, 2022 at 11:40 AM