Table scan and random access
Compared to indexes, sequential and random table access (rnd_* methods) are much simpler. We have discussed them extensively in previous chapters. In our engine there is no way to scan all of the rows in a sequential order—Tokyo Cabinet has no API for that. Like other engines that store the row data in the index by primary key, we convert the table scan into the primary key index scan.
There is only one detail worth mentioning. As we remember, the call sequence for the sequential table scan is rnd_init(), rnd_next()
many times, and rnd_end()
. While for the index scan it is index_init(), index_first(), index_next()
many times, and index_end()
. See? In the indexed case, MySQL calls a special method to retrieve the first row in the sequence. In the table scan case, the same method is used to get the first and all subsequent rows. The indexed call sequence fits the Tokyo Cabinet logic pretty well, as we have seen already. The table scan does not; we need to know...