8.3.3 SPATIAL Index Optimization空间索引优化

MySQL permits creation of SPATIAL indexes on NOT NULL geometry-valued columns (see Section 11.4.10, “Creating Spatial Indexes”). MySQL允许在非空几何值列上创建空间索引(请参阅第11.4.10节,“创建空间索引”)。The optimizer checks the SRID attribute for indexed columns to determine which spatial reference system (SRS) to use for comparisons, and uses calculations appropriate to the SRS. 优化器检查索引列的SRID属性,以确定要用于比较的空间引用系统(SRS),并使用适合SRS的计算。(Prior to MySQL 8.0, the optimizer performs comparisons of SPATIAL index values using Cartesian calculations; the results of such operations are undefined if the column contains values with non-Cartesian SRIDs.)(在MySQL 8.0之前,优化器使用笛卡尔计算执行SPATIAL索引值的比较;如果列包含具有非笛卡尔SRID的值,则此类操作的结果是未定义的。)

For comparisons to work properly, each column in a SPATIAL index must be SRID-restricted. 为了使比较正常工作,SPATIAL索引中的每一列都必须受到SRID限制。That is, the column definition must include an explicit SRID attribute, and all column values must have the same SRID.也就是说,列定义必须包含显式SRID属性,并且所有列值必须具有相同的SRID

The optimizer considers SPATIAL indexes only for SRID-restricted columns:优化器只考虑SRID限制列的SPATIAL索引:

The optimizer ignores SPATIAL indexes on columns that have no SRID attribute (and thus are not SRID-restricted). 优化器忽略没有SRID属性(因此不受SRID限制)的列上的SPATIAL索引。MySQL still maintains such indexes, as follows:MySQL仍然维护这样的索引,如下所示: