Re: Query performance issue - Mailing list pgsql-performance

From Tomas Vondra
Subject Re: Query performance issue
Date
Msg-id 20200904213635.hvz2pxmmj3tatv26@development
Whole thread Raw
In response to Query performance issue  (Nagaraj Raj <nagaraj.sf@yahoo.com>)
List pgsql-performance
On Fri, Sep 04, 2020 at 09:18:41PM +0000, Nagaraj Raj wrote:
> I have a query which will more often run on DB and very slow and it is doing 'seqscan'. I was trying to optimize it
byadding indexes in different ways but nothing helps.
 
>Any suggestions?
>

1) It's rather difficult to read the query plan as it's mangled by your
e-mail client. I recommend to check how to prevent the client from doing
that, or attaching the plan as a file.

2) The whole query takes ~3500ms, and the seqscan only accounts for
~200ms, so it's very clearly not the main issue.

3) Most of the time is spent in sort, so the one thing you can do is
either increasing work_mem, or adding index providing that ordering.
Even better if you include all necessary columns to allow IOS.


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-performance by date:

Previous
From: Nagaraj Raj
Date:
Subject: Re: Query performance issue
Next
From: Michael Lewis
Date:
Subject: Re: Query performance issue