Sorry if this is not the right place for this post.
I'm wondering thow query like following work on the b-tree in innodb:
select * from table where id between 1 and 5 OR id between 100000 and 100005
select * from table where id between 1 and 5 AND id between 100000 and 100005
here let's assume that id is the primary key and that id between 1 and 5 is on on one sub-b-tree and id between 100000 and 100005 is on another sub-b-tree, so how did innodb handle such query while using the cluster index?
When we search throuh the b-tree, we will go through the sub-b-tree that contains the id between 1 and 5, and how to do next?
Do innodb find the leaf node that contains the record whose id is 1 and then scan through the leaf node of b-tree one by one and examine if the records on these nodes fit the query condtion (id between 1 and 5 OR id between 100000 and 100005)?
I think this solution is not so effective, so how did innodb handle such an query? Scan the b-tree twice ?
Can someone give me some hints?
Thank you very much!
I'm wondering thow query like following work on the b-tree in innodb:
select * from table where id between 1 and 5 OR id between 100000 and 100005
select * from table where id between 1 and 5 AND id between 100000 and 100005
here let's assume that id is the primary key and that id between 1 and 5 is on on one sub-b-tree and id between 100000 and 100005 is on another sub-b-tree, so how did innodb handle such query while using the cluster index?
When we search throuh the b-tree, we will go through the sub-b-tree that contains the id between 1 and 5, and how to do next?
Do innodb find the leaf node that contains the record whose id is 1 and then scan through the leaf node of b-tree one by one and examine if the records on these nodes fit the query condtion (id between 1 and 5 OR id between 100000 and 100005)?
I think this solution is not so effective, so how did innodb handle such an query? Scan the b-tree twice ?
Can someone give me some hints?
Thank you very much!