Re: Indexing on JSONB field not working

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Zhihong Zhang <zhihong(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Indexing on JSONB field not working
Date: 2020-01-03 13:54:23
Message-ID: CAMkU=1wt4Aj9mHyzUXwo3W14xhsdowSxne9ygUFa=Pz=OPnE9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jan 2, 2020 at 4:49 PM Zhihong Zhang <zhihong(at)gmail(dot)com> wrote:

> I think the root cause of my problem is that the “CREATE INDEX” with
> expression wouldn’t generate stats automatically. Running ‘Analyze’
> manually solves the problem in most cases but sometimes I have to restart
> the server.
>

You told us vociferously that ANALYZE was run after the index was created.

> So I like to report 2 bugs,
>
> 1. “CREATE INDEX” with expression should generate stats automatically.
>

I thought we did do something about that in a recent release, having the
CREATE INDEX send some message to the stats collector which would cause the
autovacuum launcher to analyze it the next time nap-time was up. But I
can't find it in the commit log, nor find the behavior. Maybe this was
discussed but not implemented.

>
> 2. Auto-analyze should generate stats if it is not available, regardless
> of the number of records changed.
>

If the table gets auto-analyzed, then it does generate the stats. But it
doesn't fire auto-analyze just to generate those stats. Is your complaint
that it doesn't run, or that it does run but doesn't collect the stats? If
the latter, then no one can reproduce it, other than through permissions
issues which apparently don't apply to you.

Cheers,

Jeff

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2020-01-03 14:14:48 Re: Indexing on JSONB field not working
Previous Message Tom Lane 2020-01-03 13:37:37 Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes