Re: BUG #13874: The index of a json field which is created after data are inserted doesn't work.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: hukim99(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13874: The index of a json field which is created after data are inserted doesn't work.
Date: 2016-01-19 04:15:11
Message-ID: 29066.1453176911@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> On Mon, Jan 18, 2016 at 9:39 PM, <hukim99(at)gmail(dot)com> wrote:
>> The only difference between two instructions above is whether the index is
>> created before or after data insertion. Isn't it a bug?

> My guess is that there are invalid statistics on this table. If you
> run ANALYZE on json_test you should be able to see a sequential scan
> in the first case as well. It is weird that the planner chooses a
> bitmap scan in the first case for one tuple.

Yes, after an ANALYZE you'd get the same plan either way. The difference
in behavior here is because you get sort of a half-baked ANALYZE
(specifically, an update in the table's recorded tuple count) at the time
of CREATE INDEX. I don't think this is a bug; and I note that for this
size of table, it really hardly matters which plan the planner chooses.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-01-19 04:17:40 Re: BUG #13875: Error explaining query
Previous Message Michael Paquier 2016-01-19 01:32:52 Re: BUG #13874: The index of a json field which is created after data are inserted doesn't work.