对于查找最近邻居之类的事情,我可以理解 R=Tree 可以胜过 B-Tree。R-Tree 可以踢出更明显的假点。
然而,对于矩形中的一个点的简单检查,它是有效的
分钟
如果 x 和 y 由 b 树索引,它们也可以剔除很多假点。
所以我做了一个空间索引的实验
SELECT DISTINCT
TB.ID,
TB.Latitude,
TB.Longitude,
111151.29341326*SQRT(pow(-6.185-TB.Latitude,2)+pow(106.773-TB.Longitude,2)*0.98839228980165) AS Distance
FROM
`tablebusiness` AS TB
join tableauxiliary as TA on TA.BusinessID=TB.ID
WHERE
MBRContains(
GeomFromText ('MULTIPOINT(-6.2317830813328 106.72621691867,-6.1382169186672 106.81978308133)'),
TA.Latlong
)
AND
MATCH (FullTextSearch) AGAINST ('kucing*' IN BOOLEAN MODE)
ORDER BY
Distance
LIMIT
0, 20
Run Code Online (Sandbox Code Playgroud)
这是相当快的。.24 秒
然后我做
SELECT DISTINCT
TB.ID,
TB.Latitude,
TB.Longitude,
111151.29341326*SQRT(pow(-6.185-TB.Latitude,2)+pow(106.773-TB.Longitude,2)*0.98839228980165) AS Distance
FROM
`tablebusiness` AS TB
join tableauxiliary as TA
WHERE
-6.2317830813328 < TB.Latitude
AND
TB.Latitude …
Run Code Online (Sandbox Code Playgroud)