Hello, I like to check my understanding on this matter. Is it true that for table b-trees, all data resides in leaf cells but for index b-trees data is stored both in the interior and leaf cells (It is stored as payload in the interior cell as key + rowid after the left pointer). And there is no duplication in data so you can’t find all the rowids in the leaf cells for index b-trees.
My reason for this conclusion is because when running ./your_program.sh companies.db "SELECT id, name FROM companies WHERE country = 'eritrea'" initially locally by just adding the rowids I get from matching key at the index leaf cells, I get the following output:
121311|unilink s.c.
2102438|orange asmara it solutions
6634629|asmara rental
However, the row 5729848|zara mining share company is missing. I still managed to pass the online test cases as I think this test case is omitted or I somehow didn’t encounter it since its random?
It is only when I also add the rowids from the payload of the interior cells where I managed to get the missing rowid (5729848).
Please correct me if I am wrong! I’m new to this as well. Thank you
Hi andy! Thank you for the quick response. I went to check and realized that my rootpage for idx_companies_country is 4 and my database seem to be much smaller with ending address 0x776000
I checked the readme and it says companies.db:
This is a small version of the test database used in the index-scan stage.
It contains one table: companies, and one index: idx_companies_country
It is ~7MB in size.
Am I right to say that my data used locally is different from the one you have attached? (That’s the full) And for this smaller database the data exist in the interior cell instead of all in the leafs.
I went to check and I think the interior page lies in pagenumber 1849 with an offset of 7569408 so in hex 738000 and I checked I see the entry for row id of zara mining share somewhere near it as seen in the screenshot below: