# where the records live Orchestra's record stores are rows of one SQLite database, `/orchestra.db`, reached through [chrisflav/db](https://github.com/chrisflav/db). This is the description of what is there: the schema, the connection, the store APIs, and the one-time import of the JSON directories the records used to be. ## why Every record store used to be a directory of one JSON file per record, and every listing read the whole directory: `TaskStore.loadAllTasks`, `Queue.loadAllEntries`, `Queue.loadAllConcertRuns` and `Interactive.loadAllSessions` opened, read and parsed every file they owned and then sorted in memory. Those listings ran on every dashboard request, on every daemon claim, in the task reaper every thirty seconds, in the dispatcher on every listener tick, and in the spawn-policy check of every `queue_task` call. `Interactive.readEvents` read the whole transcript backwards to answer "anything after seq N", three times a second per attached client. With a few thousand tasks that was thousands of `open`/`read`/`parse` per tick. Each of those is one query now, with indexed lookups by id and by status, and paging and counting that do not materialise the collection. On a queue of five thousand entries, reading all of them takes about 350 ms; asking for the fifty that are pending takes about 5 ms, and one page of twenty task records out of five thousand takes about 3 ms. ## scope **In the database** (the records orchestra itself writes and reads back): | store | before | table(s) | | --- | --- | --- | | task records | `/tasks/.json` | `task` | | series pointers | `/series/.json` | `series` | | queue entries | `/queue/.json` | `queue_entry` | | concert runs | `/concerts/.json` | `concert_run` | | interactive sessions | `/interactive//session.json` | `interactive_session` | | interactive transcripts | `/interactive//events.jsonl` | `interactive_event` | | usage source state | `/usage//