Re: Minor inaccuracy in jsonb_path_ops documentation - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Minor inaccuracy in jsonb_path_ops documentation
Date
Msg-id 20776.1406239333@sss.pgh.pa.us
Whole thread Raw
In response to Minor inaccuracy in jsonb_path_ops documentation  (Peter Geoghegan <pg@heroku.com>)
Responses Re: Minor inaccuracy in jsonb_path_ops documentation  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers
Peter Geoghegan <pg@heroku.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Why does xlog.c not treat COMMIT_PREPARED/ABORT_PREPARED as commit/abort?
Next
From: Andres Freund
Date:
Subject: Re: Why does xlog.c not treat COMMIT_PREPARED/ABORT_PREPARED as commit/abort?