Arrays 使用Mariadb为整数的JSON数组编制索引?
我将整数数组作为json存储在mariadb(10.3.23)表中: 结果:Arrays 使用Mariadb为整数的JSON数组编制索引?,arrays,json,mariadb,query-optimization,generated-columns,Arrays,Json,Mariadb,Query Optimization,Generated Columns,我将整数数组作为json存储在mariadb(10.3.23)表中: 结果: [903, 1258, 1261, 393] +----------+ | count(*) | +----------+ | 9696 | +----------+ 1 row in set (2.084 sec) 要检索与特定id匹配的条目,可以执行以下操作: SELECT SQL_NO_CACHE count(*) FROM dw.final_document wh
[903, 1258, 1261, 393]
+----------+
| count(*) |
+----------+
| 9696 |
+----------+
1 row in set (2.084 sec)
要检索与特定id匹配的条目,可以执行以下操作:
SELECT SQL_NO_CACHE
count(*)
FROM
dw.final_document
where
JSON_CONTAINS(tag_list, 684 ) ;
结果:
[903, 1258, 1261, 393]
+----------+
| count(*) |
+----------+
| 9696 |
+----------+
1 row in set (2.084 sec)
但是,如果没有索引,性能就不好(在1M行表中为2秒)
为json的特定字段编制索引的可能性已经有很好的文档记录()
您可以在生成的列上添加索引,如下所示:
ALTER TABLE test_features
ADD COLUMN street VARCHAR(30)
GENERATED ALWAYS AS (json_unquote(json_extract(`feature`,'$.properties.STREET'))) VIRTUAL;
是否有类似的方法对整数数组进行索引?