pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Shrikant Bhende <shrikantpostgresql@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: Slow running query
Date: Wed, 11 Dec 2019 10:32:49 -0500
Message-ID: <14517.1576078369@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMTQpJD-DvtO=1XL-VC85iFRDTSYqz-b_Ha6L1dif=4ZO=hbwg@mail.gmail.com>
References: <CAMTQpJD-DvtO=1XL-VC85iFRDTSYqz-b_Ha6L1dif=4ZO=hbwg@mail.gmail.com>

Shrikant Bhende <shrikantpostgresql@gmail.com> writes:
> Below is the query which is running very slow, can anyone suggest any
> improvement for the same to make it faster.

Not when you haven't given us any supporting data :-(.  There's some
advice about how to ask useful performance questions here:

https://wiki.postgresql.org/wiki/Slow_Query_Questions

However, just scanning your EXPLAIN output, it seems that the bulk
of the time is being spent inside two user-defined functions:

>                                              ->  Function Scan on get_num_connections f  (cost=0.25..10.25 rows=1000 width=24) (actual time=22331.461..22331.479 rows=263 loops=1)
...
>                                              ->  Function Scan on get_num_proprietary f_1  (cost=0.25..10.25 rows=1000 width=24) (actual time=4052.081..4052.085 rows=26 loops=1)
...
>  Planning time: 18.362 ms
>  Execution time: 33944.679 ms

ie, 26 of the 34 seconds are being spent there.  You're not going to be
able to move the needle very far unless you can make those a lot cheaper.

I notice that the first thing the plan does with these is FULL JOIN them
to each other, which seems suspiciously like a performance anti-pattern.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <14517.1576078369@sss.pgh.pa.us>
Permalink:  ../14517.1576078369@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14517.1576078369@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, shrikantpostgresql@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Slow running query
  In-Reply-To: <14517.1576078369@sss.pgh.pa.us>

* 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