I have a query like this:
SELECT id, terrain, occupied, c_type
FROM map
WHERE x >= $x-$radius
AND x <= $x+$radius
AND y >= $y-$radius
AND y <= $y+$radius
ORDER BY
x ASC,
y ASC
My table looks like this:
CREATE TABLE `map` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`occupied` tinyint(2) NOT NULL DEFAULT '0',
`c_type` tinyint(4) NOT NULL DEFAULT '0',
`x` int(11) NOT NULL,
`y` int(11) NOT NULL,
`terrain` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4_general_ci
I removed all indexes except PRIMARY KEY, because I am unsure how does indexing works with SQL. What can I do to tune this query? Thanks...
This is not a duplicate,check comments!