升级到 mariadb 10.5.11 后,我遇到了一个奇怪的索引问题。
具有两列Type
(varchar) 和Point
(point)的简单表
(Tindex)上的索引和( Type
Pindex) 上的空间索引Point
现在像这样的查询
SELECT X(Point) as x,Y(Point) as y,hotels.Type FROM hotels WHERE (Type in ("acco")) AND MBRContains( GeomFromText( 'LINESTRING(4.922 52.909,5.625 52.483)' ), hotels.Point)
;
结果是
查询错误 (1207):在 READ UNCOMMITTED 事务期间无法获取更新锁
虽然两者
SELECT X(Point) as x,Y(Point) as y,hotels.Type FROM hotels USE INDEX (Pindex) WHERE (Type in ("acco")) AND MBRContains( GeomFromText( 'LINESTRING(4.922 52.909,5.625 52.483)' ), hotels.Point)
;
和
SELECT X(Point) as x,Y(Point) as y,hotels.Type FROM hotels USE INDEX (Tindex) WHERE (Type in ("acco")) AND MBRContains( GeomFromText( 'LINESTRING(4.922 52.909,5.625 52.483)' ), hotels.Point)
;
工作正常。正如 mariadb 10.5.10 所做的那样
| 编号 | 选择类型 | 表| 类型 | 可能的键 | 关键 | key_len | 参考 | 行 | 额外 |
| 1 | 简单 | 酒店 | 范围|过滤器 | 类型,Pindex | Pindex|类型 | 34|302 | 空 | 340 (4%) | 使用哪里;使用 rowid 过滤器 |