I have two tables: one with points, the other with polys.
CREATE TABLE `points` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`point` point NOT NULL,
PR
You can force MySQL to use the index by encapsulating the subselect in a function.
For example:
DELIMITER $$
DROP FUNCTION IF EXISTS `GetMyPolygon`$$
CREATE DEFINER=`root`@`localhost` FUNCTION `GetMyPolygon`(p POINT) RETURNS INTEGER
BEGIN
DECLARE ret INTEGER;
SET ret = (SELECT range_id FROM ranges WHERE ST_CONTAINS(poly, p) ;
RETURN ret;
END$$
If polygons do not overlap, you can then make:
SELECT *, GetMyPolygon(point) FROM points
If they do overlap, but there a few, you could make a similar function that makes group_concat...