Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes

From: Arjun Ranade <ranade(at)nodalexchange(dot)com>
To: pryzby(at)telsasoft(dot)com
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes
Date: 2018-09-27 19:51:32
Message-ID: CANrrCRyCymUyGZEjmM7kYchChFknHV4Saq3bpQj1yto_6mhtGg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"As a workaround/test, you could maybe add an expression index
ON( (vw2.product_group_name ||'.'|| vw2.product_node_name) )"

Unfortunately, vw2 is a view, but I had a similar thought. I'm looking
into splitting i.product-node_name into separate columns though, thanks!

On Thu, Sep 27, 2018 at 3:33 PM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:

> 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
>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Vladimir Ryabtsev 2018-09-27 20:39:32 Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes
Previous Message Arjun Ranade 2018-09-27 19:37:57 Re: SELECT statement returns in 10seconds, but INSERT/CREATE TABLE AS with same SELECT takes 7 minutes