From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Saurabh Sehgal <saurabh.r.s@gmail.com>
Cc: Pgsql Performance <pgsql-performance@lists.postgresql.org>
Subject: Re: Slow Planning Times
Date: Wed, 06 Apr 2022 22:57:40 -0400
Message-ID: <3221252.1649300260@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwY3yfaZrnWt6pCgvNnG93kprLjHNbeJ5w1t=0tBmdLrDw@mail.gmail.com>
References: <CAB0Jq2KhM6guH6cPtV+upKQ=SSw6m3oXaQO=XnjqzTnyp+KEyw@mail.gmail.com>
<CAKFQuwY3yfaZrnWt6pCgvNnG93kprLjHNbeJ5w1t=0tBmdLrDw@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Apr 6, 2022 at 5:27 PM Saurabh Sehgal <saurabh.r.s@gmail.com> wrote:
>> I have the following query:
>> I don't think it is super complex. But when I run explain analyze on this
>> I get the following:
>> Planning Time: 578.068 ms
>> Execution Time: 0.113 ms
> The fundamental issue here is that you have basically 12 conditions across
> 5 tables that need to be evaluated to determine which one of the 1,680
> possible join orders is the most efficient.
A 5-way join doesn't seem particularly outrageous. But I'm wondering
if these are all plain tables or if some of them are actually complex
views. Another possibility is that the statistics target has been
cranked to the moon and the planner is spending all its time sifting
through huge statistics arrays.
It'd be interesting to see the actual schemas for the tables,
as well as EXPLAIN's output for this query. I'm wondering
exactly which PG version this is, too.
regards, tom lane
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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, saurabh.r.s@gmail.com, pgsql-performance@lists.postgresql.org
Subject: Re: Slow Planning Times
In-Reply-To: <3221252.1649300260@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