AltSql is a database for both ends of an IoT link. On a sensor, AltSql Core stores key-value and time-series data in the device’s flash. At the gateway, those same records answer SQL, byte for byte, with nothing translated on the way. On 5 October its two products, AltSql Core and AltSql DB, went open source under the Apache License 2.0. On 8 October, 0.4.0 put them on one version number and brought binaries for every system it supports, Linux ARM64 and macOS included.
What’s in the Repository
Core is one C99 file. DB, the gateway database built on it, is a single C file of 5,470 lines, and it keeps a whole fleet in one database file, built as a copy-on-write B-tree with a pair of commit headers. The code comes with its tests, the logs behind Core’s and DB’s published numbers, a browser demo and two shells: altsql plays the device and altsql-db plays the gateway.
Indexes, Then Binaries
AltSql DB 0.3 added secondary indexes, up to eight a table, and a savepoint around each statement inside a transaction, so one failed statement no longer spoils the rest. In one measured run on a million rows, an indexed lookup took 0.7 ms against 132.2 ms for reading every row. Keyed reads were already quick. Measured again on 0.3, the middle of three runs, cached reads by key on the direct path, which skips SQL, ran 4.4 times as fast as SQLite through SQL (5 times in the first measurement).
0.4.0 was the first release built and checked by the project’s release workflow. It has static binaries for Linux on x86-64 and ARM64, and binaries for macOS on Apple silicon and Intel. The tests now run on every push, on Linux x86-64, Linux ARM and macOS, and getting there turned up two portability snags. A sync call didn’t compile on macOS, and some tests made different data on different compilers, because C doesn’t fix the order in which a function’s arguments are worked out. Both are fixed. 0.4.1 added the license notice that musl, the C library inside the static Linux builds, asks for.
Onto Real Hardware
Every AltSql figure so far comes from simulation on a PC. Core’s Beta takes the engine onto real chips, in an estimated 16 weeks. DB doesn’t have to wait for those boards: its own Beta, on a Linux gateway fed by devices running Core, is next as well, with no duration set yet. 0.4.1 is on the releases page.