Sql Postgres中JSON查询内的OR子句

Sql Postgres中JSON查询内的OR子句,sql,postgresql,jsonb,Sql,Postgresql,Jsonb,在Postgres JSONB中,是否可以执行以下操作: where ( description ->'Auditor'->'1'->'Internal|External' is not null ) 与此相反: where ( description ->'Auditor'->'1'->'Internal' is not null or description ->'Auditor'->'1'->'External' is

在Postgres JSONB中,是否可以执行以下操作:

where (
  description ->'Auditor'->'1'->'Internal|External' is not null
)
与此相反:

where (
  description ->'Auditor'->'1'->'Internal' is not null
  or
  description ->'Auditor'->'1'->'External' is not null
)

您可以使用
?|
检查jsonb值是否具有一组键中的任何键:

where description->'Auditor'->'1' ?| array ['Internal','External']

太棒了。有趣的是,
?|
比使用两个单独的查询要慢。3800毫秒与之前的600毫秒相比。