AltSql AltSql DB demo About AltSql DB

AltSql DB ยท Live demo

A whole fleet in one file

Twelve devices run AltSql Core, each on its own flash chip, and every ten seconds each saves a reading and sends the gateway what it has not confirmed yet, as the bytes sit in its flash. The gateway keeps every device in one AltSql DB file, the devices' bytes unchanged, and answers two ways: SQL, and a direct path with no SQL step at all.

Simulated devices and file, real code. AltSql Core and AltSql DB run in this page, compiled to WebAssembly. The chips and the gateway's file are emulated in memory, so the power can be cut at any write.

Try this

Loading the modules

The fleet

0:00
Each step is ten seconds of the devices' time: a reading from each, then a batch from each to the gateway.

The gateway's file

One AltSql DB file for every device: a copy-on-write B-tree with two commit headers, one transaction for each batch.

Ask the gateway

Core's own SQL over the tree. The synced table temps has the columns device and seq, then the device's own: time, machine, temp. The table kv holds every device's key-value pairs. WHERE picks the plan: a point lookup, a key list, a range scan, a range for each device, or a full scan.

 

The direct path beside SQL

A device's newest reading, read a thousand times each way. The direct path is altsql_db_row_last and altsql_db_row_read: one walk down the tree, no parser, no planner. SQL reads the same reading with ORDER BY time DESC LIMIT 1.

Cut the gateway's power

The fleet runs on, and the power goes during a commit: while it writes its pages, or while it writes its commit header. Any mix of the writes since the last sync survives, and the write that was cut lands in part, sector by sector. Then the file is opened again, both headers are checked page by page, and each device resends from the position the gateway now holds for it.

What is real here

Real

  • AltSql Core on each device and AltSql DB on the gateway: the prototypes' own code, compiled to WebAssembly.
  • Sync as it works: each batch is the device's records as they sit in its flash, applied in one transaction with the device's new position.
  • The SQL, the plans, the direct path, the bytes shown, the power cuts and the checks after them.

Simulated

  • The devices' flash chips and the gateway's file, emulated in memory. The radio between them: a batch of up to 1,200 bytes from each device every ten seconds.
  • The readings: a temperature pattern for each device. The fleet had run for an hour before the page started.
  • The timings are this browser's, for code compiled to WebAssembly, not a gateway's.