pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Devinder K Rajput <Devinder.Rajput@ipaper.com>
To: pgsql-admin@postgresql.org
Subject: Query takes too long to run
Date: Mon, 7 Oct 2002 17:20:59 -0500
Message-ID: <OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com> (raw)

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





view thread (2+ messages)  latest in thread

Message-ID: <OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com>
Permalink:  ../OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com/
Also on:    postgresql.org/message-id/OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: Devinder.Rajput@ipaper.com
  Subject: Re: Query takes too long to run
  In-Reply-To: <OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com>
  References: <OF2BFCAFEF.5AC8B24E-ON86256C4B.0079E490@ipaper.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox