I'm upgrading an inventory database and would like to speed up the queries. The bulk of the sorting is on 2 columns each of which is a range. For example.
SELECT ....
WHERE price BETWEEN 10.50 AND 34.20
AND date BETWEEN 1311264060 AND 1313942460
ORDER BY stockNo LIMIT 100
I understand that because ranges are used, MySQL can only use an index on one column. In other words, it can use an index to extract the records matching the price range, but then has to resort to a table scan to find the records matching the date range.
I had the idea of pretending that the price and data were x and y axis and filling a column of spatial data and taking advantage of MySQLs spacial searches and R-TREE indexes to extract the data.
Does anyone have experience of R-TREES? Is this likely to give me a speed-up?