Re: Wrong PostgreSQL Plan

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Virendra Kumar <viru_7683(at)yahoo(dot)com>
Cc: Pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Wrong PostgreSQL Plan
Date: 2020-05-06 01:26:17
Message-ID: CAKFQuwZr7XZTB8mjPNKgegf_goPZ1PTJdRD5YThSRMoLjSyd=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 5, 2020 at 6:15 PM Virendra Kumar <viru_7683(at)yahoo(dot)com> wrote:

> Optimizer is behaving little weird in the sense that for change in one
> filter
>

You mean when you change the date equality filter to a more recent date?

> it is using NESTED LOOP JOIN and running for over 30 seconds whereas for
> other filter is working fine using HASH JOIN and under mili seconds.
>

Which means it runs to completion which means EXPLAIN ANALYZE is possible
and considerably more helpful.

We have played little bit around default_statistics_target, sometimes it
> worked when the setting is around 1500 other times it doesn't work even
> with setting as high as 5000. Is there anything community can suggest us in
> resolving this?
>

Given that adding more data causes the good plan to stop working I would
have to say that increasing how often you run ANALYZE on the table,
irrespective of default_statistics_target, is probably a good thing to try.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ricky Ramirez 2020-05-06 01:27:15 Re: Temporary table has become problematically persistent
Previous Message Virendra Kumar 2020-05-06 01:15:21 Wrong PostgreSQL Plan