I want to use b-tree for index, but I can't think out an solution for OR query.
For OR query, I mean something like select * from table where id between 1 and 5 OR id between 10 and 15;
if I use id as the key in the b-tree, than how can I do query like above on the b-tree?
when search through the b-tree, assume that the key that are smaller than 6 and bigger than 6 is on different sub-trees, than when the search path go through the sub-tree that contaions the key that are smaller than 6, id that between 1 and 5 can be retrived, but what about id that between 10 and 15?
Do I have to use the b+tree,and when I found the key which points to id 1 , I just keep scan through the leaf nodes one by one until I found the key which points to id 15? Is it bad solution for this kind of query: select * from table where id between 1 and 5 OR id between 10000000 and 10000005???
Or is there any other solutions?
Thank you very much!