Re: Minor inaccuracy in jsonb_path_ops documentation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Minor inaccuracy in jsonb_path_ops documentation
Date: 2014-07-24 22:02:13
Message-ID: 20776.1406239333@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Geoghegan <pg(at)heroku(dot)com> writes:
> The jsonb documentation says of the jsonb_path_ops GIN opclass:
> """
> A disadvantage of the jsonb_path_ops approach is that it produces no
> index entries for JSON structures not containing any values, such as
> {"a": {}}. If a search for documents containing such a structure is
> requested, it will require a full-index scan, which is quite slow.
> jsonb_path_ops is therefore ill-suited for applications that often
> perform such searches.
> """

> The reference to a full index scan seems questionable.

Well, if you get an indexscan, it will be a full index scan, so
I find this warning appropriate.

The fact that the planner can avoid that in the presence of a
simple constant comparison value doesn't make it a good idea to
use jsonb_path_ops indexes if you do this type of query a lot,
because in some usages the planner won't see a constant comparison
value, and if so it'll likely choose an indexscan by default.

Getting into exactly when the planner will or won't save your bacon
is the kind of detail I'd rather not put in user-facing docs.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-07-24 22:04:27 Re: Why does xlog.c not treat COMMIT_PREPARED/ABORT_PREPARED as commit/abort?
Previous Message Tom Lane 2014-07-24 21:53:17 Why does xlog.c not treat COMMIT_PREPARED/ABORT_PREPARED as commit/abort?