spanspan
spanspan on Hacker News
Fair. It’s “inspired by”, not a “clone”. Frankly, I don’t think these terms are that specific, that one couldn’t level the same point against “inspired by”.. in what sense is it inspired?
I began using python as a way to "mock" out the overall design; intending to re-implement it in rust. The main reasoning for using python: was the ability to focus on "high-level" concepts and speed of tinkering.
This implements a single process, single thread, single connection database- so performance and low-level concurrency control were not explicit goals or really optimized for. For those (real-live concerns) rust or C++ are much better; but also come with their set of complexities.
Re: ACID guarantees
It doesn't have a notion of atomically batching multiple statements, i.e. transaction. But beyond that, it's a single file database,
which can only have a single process (learndb instance) that is operating on the database (file). So you get consistency and isolation via being a single connection database. Durability, you get to the extent that the file system is durable. So it's somewhere on the ACIDity spectrum.
Re: Query planning/optimization
I haven't implemented this; but I've considered where the optimization could module sit:
The parser spits out an AST. This or a derived intermediate representation could be optimized,i.e. the AST could be rewritten or nodes deleted,
before the VM executes the AST.
This string is the grammar that lark uses to parse the user submitted sql into an AST. This parsing is far more complete and robust than what doing this in pure python would allow (without of course implementing the entire lexer and parser that lark implements).
There may be some post parsing validation that can be done here- but that would be something that's beyond the domain of the parser.
Single file, embedded database with similar logical organization
It would be a fun exercise to implement something like TPC-C for learndb and see how this done.
Cool stuff. I had similar intuitions- Python allow me to focus on the high-level concepts. Albeit, there were times where I wished I had gone with a statically-typed + compiled language.
Most definitely. The b-tree implementation was the first motivation for starting the project. Especially, all the details around node rebalancing and splitting. And the fact that it was an on-disk structure, added another wrinkle to the thinking about the impl
Posted by
spanspan on Sunday August 13, 2023 @04:32PM
from the show-hn dept.
https://github.com/spandanb/learndb-py
I wrote a relational database management system (RDBMS) (sqlite clone) from scratch in pure Python.
Posted by
spanspan on Friday May 07, 2021 @07:06PM
from the show-hn dept.
Posted by
spanspan on Sunday September 22, 2019 @12:56PM
from the show-hn dept.
Posted by
spanspan on Wednesday January 04, 2017 @06:37PM
from the medium.com dept.