pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: David Wheeler <dwheeler@dgitsystems.com>
To: pgsql-performance@lists.postgresql.org <pgsql-performance@lists.postgresql.org>
Cc: Cameron Redpath <credpath@dgitsystems.com>
Subject: Re: Slow planning, fast execution for particular 3-table query
Date: Mon, 04 Nov 2019 05:37:00 +0100
Message-ID: <2e94543c5f92f6902ae51a5e6f4f569558fb548a.camel@cybertec.at> (raw)
In-Reply-To: <175BE386-F861-4064-8B5D-93E63BD90F13@dgitsystems.com>
References: <175BE386-F861-4064-8B5D-93E63BD90F13@dgitsystems.com>

On Mon, 2019-11-04 at 03:04 +0000, David Wheeler wrote:
> We’re having trouble working out why the planning time for this particular query is slow
> (~2.5s vs 0.9ms execution time). As you can see below, there are only 3 tables involved
> so it’s hard to imagine what decisions the planner has to make that take so long. After
> 5 runs the prepared-statement code kicks in and it becomes quick, but it’s quite
> infuriating for the first 5 runs given the execution is so much faster. 
> 
> Are you able to give any tips what might be taking so long (and how we might improve it)?
> 
[...]
> Planning time: 2429.682 ms
> 
> Execution time: 0.914 ms

Strange.
Are any of your catalog tables unusually large?

SELECT pg_relation_size(t.oid),
       t.relname
FROM pg_class AS t
   JOIN pg_namespace AS n ON t.relnamespace = n.oid
WHERE t.relkind = 'r'
ORDER BY pg_relation_size(t.oid) DESC
LIMIT 10;

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (13+ messages)  latest in thread

Message-ID: <2e94543c5f92f6902ae51a5e6f4f569558fb548a.camel@cybertec.at>
Permalink:  ../2e94543c5f92f6902ae51a5e6f4f569558fb548a.camel@cybertec.at/
Also on:    postgresql.org/message-id/2e94543c5f92f6902ae51a5e6f4f569558fb548a.camel@cybertec.at

 · 

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-performance@postgresql.org
  Cc: laurenz.albe@cybertec.at, dwheeler@dgitsystems.com, pgsql-performance@lists.postgresql.org, credpath@dgitsystems.com
  Subject: Re: Slow planning, fast execution for particular 3-table query
  In-Reply-To: <2e94543c5f92f6902ae51a5e6f4f569558fb548a.camel@cybertec.at>

* 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