

The os interface is the layer that differs depending on which operating system sqlite was compiled for. It also keeps a cache of recently-accessed pages in memory, and determines when those pages need to be written back to disk. It is responsible for reading/writing at appropriate offsets in the database file. The pager receives commands to read or write pages of data. The B-tree can retrieve a page from disk or save it back to disk by issuing commands to the pager. The VM is essentially a big switch statement on the type of bytecode instruction.Įach B-tree consists of many nodes. It can then perform operations on one or more tables or indexes, each of which is stored in a data structure called a B-tree. The virtual machine takes bytecode generated by the front-end as instructions. the output is sqlite virtual machine bytecode (essentially a compiled program that can operate on the database). The input to the front-end is a SQL query. sqlite architecture ()Ī query goes through a chain of components in order to retrieve or modify data.

There’s lots of documentation of sqlite internals on their website, plus I’ve got a copy of SQLite Database System: Design and Implementation. The entire database is stored in a single file! Sqlite It’s modeled off sqlite because it is designed to be small with fewer features than MySQL or PostgreSQL, so I have a better hope of understanding it. To figure things out, I’m writing a database from scratch. In other words, how does a database work?
