<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:3.0cm 2.0cm 3.0cm 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DA" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p style="margin:0cm;background:white"><span lang="EN-US" style="color:black">I found out that the current indexes is not used by our code
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">in HarvestDefinitionDBDAO in the method getHarvestRunInfo().<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">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!<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">Here are the 2 different queries:<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">s = c.prepareStatement("SELECT name, harvest_num, status, MIN(startdate), MAX(enddate), COUNT(job_id)"<br>
+ " FROM jobs, harvestdefinitions"<br>
+ " WHERE harvestdefinitions.harvest_id = ? AND jobs.harvest_id = harvestdefinitions.harvest_id"<br>
+ " GROUP BY name, harvest_num, status ORDER BY harvest_num DESC");<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">and<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">s = c.prepareStatement("SELECT jobs.harvest_num, SUM(historyinfo.bytecount), "<br>
+ "</span><em><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">SUM</span></em><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">(historyinfo.objectcount)," + "</span><em><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">COUNT</span></em><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">(jobs.status)"
+ " FROM jobs, historyinfo "<br>
+ " WHERE jobs.harvest_id = ? AND historyinfo.job_id = jobs.job_id" + " GROUP BY jobs.harvest_num"<br>
+ " ORDER BY jobs.harvest_num");<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">I have verified the where clause changes by following example in our jobs database:<o:p></o:p></span></p>
<p style="background:white"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">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;<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">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 <b>and jobs.harvest_id = historyinfo.harvest_id</b> GROUP BY jobs.harvest_num ORDER BY jobs.harvest_num;<o:p></o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D"><o:p> </o:p></span></p>
<p style="mso-margin-top-alt:7.5pt;margin-right:0cm;margin-bottom:0cm;margin-left:0cm;background:white">
<span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#172B4D">Hopefully somebody can add that change to the code….<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Best regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Tue<o:p></o:p></span></p>
</div>
</body>
</html>