
Index Key Format in SQLite
Hello, I'm Maneshwar. I'm working on git-lrc : a Git hook for Checking AI generated code. In the previous sections, we saw how a table’s B+-tree works: The key is an integer ( rowid ). The data is the full table record. Indexes reverse this design. For an index entry: The key is the combined value(s) of the indexed column(s). The data is a single integer — the rowid of the corresponding table row. This inversion is the foundation of how SQLite accelerates lookups. How an Index Lookup Works Suppose we have an index on column x of table t1 . When you execute: SELECT y FROM t1 WHERE x = 456 ; The VM does not scan the entire table. Instead: It searches the index B-tree for entries where x = 456 . For each matching entry, it retrieves the stored rowid . It uses that rowid to search the table’s B+-tree. It extracts column y from the full table record. So an indexed lookup typically involves two tree searches : One in the index B-tree One in the table B+-tree Even though this means two search
Continue reading on Dev.to Webdev
Opens in a new tab


