Re: Bad plan

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Laurent Martelli <martellilaurent(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Bad plan
Date: 2018-01-23 15:18:48
Message-ID: 20180123151848.GC25452@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Jan 23, 2018 at 01:03:49PM +0100, Laurent Martelli wrote:
> Hello all,
>
> So I have a view, for which I can select all rows in about 3s (returns ~80k
> rows), but if I add a where clause on a column, it takes +300s to return
> the ~8k lines.
>
> From the plan, I see that it expects to return only 1 row and so choose to
> perform some nested loops. Of course, I did run "ANALYZE", but with no
> success.
>
> I managed to speed things up with "set enable_nestloop = false;", but is
> that the only choice I have ? Should I report a bug ?

> Here is the default plan :

Can you resend without line breaks or paste a link to explain.depesz?

The problem appears to be here:

-> Nested Loop Left Join (cost=32067.09..39197.85 rows=1 width=276) (actual time=342.725..340775.031 rows=7359 loops=1)
Join Filter: (sh.share_holder_partner = partner.id)
Rows Removed by Join Filter: 204915707

Justin

In response to

  • Bad plan at 2018-01-23 12:03:49 from Laurent Martelli

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pavan Teja 2018-01-23 15:20:15 Re: 8.2 Autovacuum BUG ?
Previous Message Andreas Kretschmer 2018-01-23 14:57:40 Re: 8.2 Autovacuum BUG ?