From: Justin Pryzby <pryzby@telsasoft.com>
To: Arjun Ranade <ranade@nodalexchange.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes
Date: Thu, 27 Sep 2018 14:33:14 -0500
Message-ID: <20180927193313.GI776@telsasoft.com> (raw)
In-Reply-To: <CANrrCRy_HSsYCTDVH+EtDoBJzFiEob3Nd5bztmno5V13WFWOjQ@mail.gmail.com>
References: <CANrrCRxsC3wr711bjAJ4zK_16vF-qQHZXjSJTstbQt9kG5QDSw@mail.gmail.com>
<20180927185224.GF776@telsasoft.com>
<CANrrCRy_HSsYCTDVH+EtDoBJzFiEob3Nd5bztmno5V13WFWOjQ@mail.gmail.com>
On Thu, Sep 27, 2018 at 03:37:57PM -0400, Arjun Ranade wrote:
> Yes, that join is concerning (red text below). The conditions all need to
> be checked so they are independent.
You can play with the join conditions to see which test is getting such a bad
estimate, or if it's a combination of tests (as I suspected) giving a bad
estimate.
There's a good chance this one isn't doing very well:
> vw2.product_group_name ||'.'|| vw2.product_node_name = i.product_node_name
As a workaround/test, you could maybe add an expression index
ON( (vw2.product_group_name ||'.'|| vw2.product_node_name) )
..and then ANALYZE. Eventually, you'd want to consider splitting
i.product_node_name into separate columns.
Justin
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: pryzby@telsasoft.com, ranade@nodalexchange.com
Subject: Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes
In-Reply-To: <20180927193313.GI776@telsasoft.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