Query takes too long to run

From: "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Query takes too long to run
Date: 2002-10-07 22:20:59
Message-ID: OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi all,

I am running the following query. It processes most of the locations fine
($Req_Store), however, on one of the locations, it takes almost 3 days to
run when it should take only about a half hour. (The query is rerun for
each location ($Req_Store)).

$result = $conn->exec("
declare my_cursor cursor for
select
invt_store,
<snip>
g.minmindays
from dioh_iminvf_inventory a,
dioh_imitmf_itemmaster b,
dioh_imvitf_vendoritem c,
dioh_samohf_saleshistory d,
dioh_leaddays_loc f,
dioh_rank g,
dioh_rankcategory h
where
h.cp_item_cat = item_cat
and
g.rankid = h.rankid
and
g.rank = invt_rank
and
a.invt_store = '$Req_Store'
and
f.lead_store = '$Req_Store'
and
f.lead_vendno = c.vitm_vendno
and
(a.invt_store,a.invt_itemno) = (d.slht_store,d.slht_itemno)
and
b.item_itemno = a.invt_itemno
and
(b.item_itemno,b.item_vendno) = (c.vitm_itemno,c.vitm_vendno)
and
d.slht_monthid between $FromMonthId and $ToMonthId
order by invt_store, invt_itemno, slht_monthid
;
");

I setup logging by setting up:
debug_level = 2 # range 0-16
debug_print_query = true
debug_pretty_print = true

I get the following message about every 15 fifteen minutes in log file and
postmaster is using up close to 99% of the CPU.
DEBUG: proc_exit(0)
DEBUG: shmem_exit(0)
DEBUG: exit(0)
/usr/bin/postmaster: reaping dead processes...
/usr/bin/postmaster: CleanupProc: pid 22128 exited with status 0

Any ideas on what is going on. Thank you for your help.

Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474

Browse pgsql-admin by date

  From Date Subject
Next Message Rafal Kedziorski 2002-10-07 23:01:09 Debug information
Previous Message Shridhar Daithankar 2002-10-07 12:47:53 Re: [GENERAL] Fast Deletion For Large Tables