说我有一张桌子:
CREATE TABLE items
(
index serial primary key,
segment int not null,
definition jsonb not null
)
definition
列如下:
{
"array": [
{ "name: "Bob", "age": 21 },
{ "name: "Alice", "age": 31 }
]
}
我希望能够索引诸如
之类的查询select * from items
where segment = 4 and definition->'array' @> '[ { "name": "Bob" } ]'::jsonb
是否可以索引此查询,索引应该是什么样的?我不需要segment
+ age
查询,只需segment
+ name
。