3 ms·
So I loaded it into memory, but still SELECTs which are true for 99% of the table (10 million+ rows) are taking 1 min 7.95 sec, which is way too long. I guess
by ca98am79 18y ago
So I loaded it into memory, but still SELECTs which are true for 99% of the table (10 million+ rows) are taking 1 min 7.95 sec, which is way too long.
I guess the best way to do this is just to create many tables which are subsets of the data for queries that return large amounts - and then come up with an algorithm which selects from these subsets based on the query? For example, if a>1 returns 99% of the data - create and store a table with this selection and if someone selects where a>1 AND b>5, query the subset.
I don't know. If I do that, I will end up with GBs and GBs of tables. I wish there were some magic algorithm to make things 10x faster.
- xirium 18y agoIf you're using MyISAM and you don't care about diskspace then you can use an R-tree index to search any two inequalities. For example, an R-tree index can be used for queries of the form A>10 AND A<100 AND B>5. Also note that R-tree indexes can be appended to my previously suggested indexes. So, an index of the form (C,D,E,R) would efficiently locate rows for a query of the form C=3 AND D=4 AND E=5 AND A>10 AND A<100 AND B>5