0
我的工作PostgreSQL的9.6的数据, 我在这里想取代表的Json关键的是jsonb类型从表中的数据, 数据是财产以后的样子如何获取PostgreSQL中使用索引由jsonb数据
[{"name": "gp1", "type": "A"}, {"name": "gp2", "type": "A"}, {"name": "gp2", "type": "A"}]
这里modules是column_name,client_modules是表名。
我使用下面的查询
create index myindex on client_modules((modules->>'name'));
问题还创建索引是,当我尝试使用下面的查询来从表中的数据
SELECT modules FROM client_modules WHERE modules @>'[{"name":"gp1"}]' or modules @> '{"name":"gp1"}';
我能中检索所需的数据,但在这种情况下,这里我的plpgsql查询运行在默认的seqscan索引上,
我也执行脚本
set enable_indexscan = on;
AND
set enable_seqscan = off;
但仍然查询没有运行在我的索引上,当我运行查询时它仍然在默认索引上运行。