From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | davidjesse091(at)aol(dot)com |
Cc: | pgsql-performance(at)lists(dot)postgresql(dot)org |
Subject: | Re: query gets very slow when :jsonb ?& operator is used |
Date: | 2018-09-07 01:39:00 |
Message-ID: | CAMkU=1w_=vKHxOgfGm18CS1tQtNEXC0rnOBtmVzQgFwQo82HtA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Thu, Sep 6, 2018 at 7:52 PM <davidjesse091(at)aol(dot)com> wrote:
> I have also asked this question on Stackoverflow and DBA stack exchange
> with no answer. It's a fairly long post, so I will post a link to it, as on
> Stackoverflow it is formatted nicely
>
>
> https://stackoverflow.com/questions/52212878/query-gets-very-slow-when-jsonb-operator-is-used
>
> Any idea why my query slows down so much when I add account.residence_details::jsonb
> ?& array['city', 'state', 'streetName'] ?
>
The planner has no insight into what fraction of rows will satisfy the ?&
condition, and falls back on the assumption that very few will. This is
(apparently) a very bad assumption, and causes it choose a bad plan.
Rewriting the `phone_number.account_id IN (subquery)` into an exists query
might help.
Cheers,
Jeff
From | Date | Subject | |
---|---|---|---|
Next Message | Dinesh Kumar | 2018-09-07 03:28:42 | Re: Performance difference in accessing differrent columns in a Postgres Table |
Previous Message | davidjesse091 | 2018-09-06 23:51:46 | query gets very slow when :jsonb ?& operator is used |