pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: sonams1209@gmail.com
Cc: pgsql-general@postgresql.org
Subject: Re: Query Tuning
Date: Tue, 01 Oct 2019 18:15:00 +0900 (Tokyo Standard Time)
Message-ID: <20191001.181500.129895819.horikyota.ntt@gmail.com> (raw)
In-Reply-To: <CAM-M3Tmz-FMGngTiUDuiREUqX6Ck5FBcwfigd8qWD8D0OauNQw@mail.gmail.com>
References: <CAM-M3Tmz-FMGngTiUDuiREUqX6Ck5FBcwfigd8qWD8D0OauNQw@mail.gmail.com>

Hello.

At Tue, 1 Oct 2019 12:42:24 +0530, Sonam Sharma <sonams1209@gmail.com> wrote in <CAM-M3Tmz-FMGngTiUDuiREUqX6Ck5FBcwfigd8qWD8D0OauNQw@mail.gmail.com>
> We have a query which is running slow and it's taking 26secs to complete..
> we have run the analyzer also and it's taking the same time.
> 
> Any tool is there for query optimization or any suggestions.

EXPLAIN ANALYZE (not just EXPLAIN) would be that. In many cases
where a query takes an unexpectedly long time, rows estimation in
some nodes would be largely different from actual rows. That
leads to a wrong query plan. EXPLAIN ANALYZE may give you a clue
for such kind of problem.

The following output comes from EXPLAIN. I suppose that you
already have a similar output having a "(actutal time=...)"
clause after the "(cost=..)"  clause.

> My query plan looks like this :
> 
> CTE Scan on approvalwflscreen (cost=8736.21..8737.25 rows=52 width=1214)
> 
> CTE constants
> 
> -> Result (cost=0.00..0.01 rows=1 width=44)
> 
> CTE approval
> 
> -> Sort (cost=7793.89..7805.22 rows=4530 width=292)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center





view thread (9+ messages)  latest in thread

Message-ID: <20191001.181500.129895819.horikyota.ntt@gmail.com>
Permalink:  ../20191001.181500.129895819.horikyota.ntt@gmail.com/
Also on:    postgresql.org/message-id/20191001.181500.129895819.horikyota.ntt@gmail.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-general@postgresql.org
  Cc: horikyota.ntt@gmail.com, sonams1209@gmail.com
  Subject: Re: Query Tuning
  In-Reply-To: <20191001.181500.129895819.horikyota.ntt@gmail.com>
  References: <CAM-M3Tmz-FMGngTiUDuiREUqX6Ck5FBcwfigd8qWD8D0OauNQw@mail.gmail.com> <20191001.181500.129895819.horikyota.ntt@gmail.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