【发布时间】:2023-03-16 08:40:01
【问题描述】:
Users表设计如下,
id - integer
workspace_id - integer
data - json
created_at - timestamp
updated_at - timestamp
json字段中存储的数据如下,
{"age": 21, "city": "London", "name": "ABC", "test_filed1": "text"}
我创建了如下索引
CREATE INDEX concurrently index_user_name ON users using gist(workspace_id, (data ->> 'name') gist_trgm_ops)
同样,我很少有用于优化查询的索引。我想知道如果我更新了 json 中没有被索引的任何一个字段,它会更新 postgres 中的索引,因为字段是同一 json 列的一部分吗?例如age 字段没有被索引,当我单独更新age 时它会更新index_user_name 索引吗?有什么方法可以单独运行更新查询,并且可以选择知道要更新哪些索引?
【问题讨论】:
标签: sql json postgresql