Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 77C6647664F for ; Mon, 7 Oct 2002 18:21:12 -0400 (EDT) Received: from mx02.ipaper.com (mx02.ipaper.com [141.129.1.11]) by postgresql.org (Postfix) with ESMTP id 4570B4764E0 for ; Mon, 7 Oct 2002 18:21:08 -0400 (EDT) Received: from S02ATW02.na.ipaper.com (s02atw02.ipaper.com [164.103.63.148]) by mx02.ipaper.com (8.10.2+Sun/8.10.2) with ESMTP id g97MM3U23710 for ; Mon, 7 Oct 2002 17:22:05 -0500 (CDT) Received: from 164.103.62.7 by S02ATW02.na.ipaper.com with ESMTP ( Tumbleweed MMS SMTP Relay (MMS v5.0)); Mon, 07 Oct 2002 17:21:01 -0500 X-Server-Uuid: AF46FF6A-C785-473C-8C32-637F1D084C73 Subject: Query takes too long to run To: pgsql-admin@postgresql.org X-Mailer: Lotus Notes Release 5.0.6a January 17, 2001 Message-ID: From: "Devinder K Rajput" Date: Mon, 7 Oct 2002 17:20:59 -0500 X-MIMETrack: Serialize by Router on SWMTA1.ipaper.com/IPAPER(Release 5.0.8 |June 18, 2001) at 10/07/2002 05:21:01 PM MIME-Version: 1.0 X-WSS-ID: 11BCD747557171-02-01 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/42 X-Sequence-Number: 5900 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, 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