Query tuning - Mailing list pgsql-sql

From
Subject Query tuning
Date
Msg-id 2B15A18AC39F2045B060BCBD4786A5D003596ED5@BLR-EC-MBX02.wipro.com
Whole thread Raw
Responses Re: Query tuning
Re: Query tuning
List pgsql-sql
<div class="Section1"><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span style="font-size:
10.0pt;font-family:"Comic Sans MS"">Hi,</span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">I have a query which is run across 3 tables JOB_TYPE_FIRST, JOB_TYPE_SECOND and
JOB_ALLOCATION_WORKLIST.</span></font><pclass="MsoNormal"><font face="Comic Sans MS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">The column JOBID is referenced in JOB_ALLOCATION_WORKLIST table and primary key in
bothJOB_TYPE_FIRST, JOB_TYPE_SECOND tables.</span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">There is one more column BOOK_ID which is supplied as the binding parameter to the
query.The query looks like:</span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">select count(distinct(j.JOBID)) as jobCount </span></font><p
class="MsoNormal"><fontface="Comic Sans MS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS"">from  JOB_TYPE_FIRST a, JOB_TYPE_SECOND b, JOB_ALLOCATION_WORKLIST j
</span></font><pclass="MsoNormal"><font face="Comic Sans MS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS"">where (( a.JOBID = j.JOBID) </span></font><p class="MsoNormal"><font face="Comic
SansMS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS"">and (a.BOOK_ID = :bookId)) </span></font><p class="MsoNormal"><font face="Comic
SansMS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS"">or ((b.JOBID = j.JOBID) </span></font><p class="MsoNormal"><font face="Comic Sans
MS"size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS"">and (b.BOOK_ID = :bookId));</span></font><p class="MsoNormal"><font face="Comic
SansMS" size="2"><span style="font-size: 
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">As the records in the database are too large it is having huge cost and stalling
theserver and takes lot of time. </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">Can anyone suggest a better way to fetch the results for the query or tune it? Any
helpwould be highly appreciated.</span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS""> </span></font><p class="MsoNormal"><font face="Comic Sans MS" size="2"><span
style="font-size:
10.0pt;font-family:"Comic Sans MS"">Thanks & Regards,</span></font><p class="MsoNormal"><font face="Comic Sans MS"
size="2"><spanstyle="font-size: 
10.0pt;font-family:"Comic Sans MS"">Kapil</span></font></div><p><strong><span style="font-size:10.0pt;font-family:
"Palatino Linotype","serif";color:green"> Please do not print this email unless it is absolutely necessary.
</span></strong><spanstyle="font-family:"Arial","sans-serif""></span><p> The information contained in this electronic
messageand any attachments to this message are intended for the exclusive use of the addressee(s) and may contain
proprietary,confidential or privileged information. If you are not the intended recipient, you should not disseminate,
distributeor copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any
attachments.<p>WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any
attachmentsfor the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted
bythis email. <p> www.wipro.com  

pgsql-sql by date:

Previous
From: "Mag Gam"
Date:
Subject: Re: Auto-formatting timestamps?
Next
From: Thomas Kellerer
Date:
Subject: xpath_table