Can spatial indexes be used for joining tables in mysql?
I have two tables with a GEOMETRY column and a spatial index on it. The table is MyISAM.
I would like to join these tables on the rows which intersect.
I cannot get mysql to use the spatial indexes despite using FORCE INDEX in my query.
The query is:
SELECT *
FROM a FORCE INDEX FOR JOIN (asidx)
JOIN b FORCE INDEX FOR JOIN (bsidx)
ON Intersects(a.g, b.g) -- g is the name of the GEOMETRY
The explain plan is:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | 1 | SIMPLE | a | ALL | asidx | NULL | NULL | NULL | 50000 | | | 1 | SIMPLE | b | ALL | bsidx | NULL | NULL | NULL | 50000 | Using where; Using join buffer |
Why aren't the indexes use? For 50k rows tables it runs for 15 minutes. How can I make it faster?