I wanted to discuss an important but more technical aspect of the recently announced MultiWikiServer plugin, which is its usage of SQLite for data storage.
TiddlyWiki on Node.js currently stores tiddlers as “.tid” files in the file system. At startup, all the tiddler files are loaded into memory for rapid access and any subsequent changes are written to the file system.
This approach is not practical for MultiWikiServer because of the need to cope with large amounts of data. Instead, I’ve chosen to use a very popular database called SQLite for data storage. SQLite is an embedded database that is designed to be integrated directly into applications like TiddlyWiki. It does not function anything like a traditional server-based database accepting asynchronous connections from multiple clients.
SQLite is blazingly fast and efficient. In fact, it has proven to be faster than storing data in the file system for some applications. It is also highly extensible. See https://sqlite.org/ for more background. To get some background, I recommend this interview with the principal author of SQLite.
The key rationale for using SQLite is that the long term plan for TiddlyWiki in the browser includes the ability to use a WASM version of SQLite to store tiddler data. (You can see my experiments on SQLite in the browser in this PR).
For users, the most important implication of the use of SQLite is that all the tiddlers are now stored in a single file with the extension .sqlite
. This is a standard file format that can be opened with many off-the-shelf tools, but there’s no question that it is a big change from seeing tiddlers as individual files.
The solution is that we will have the ability to synchronise the database with external data sources such as the file system. Of course, this is the same technique we use to process tiddlers that have been modified in memory. Overall, it’s best to consider the database as being the equivalent of the memory store used in standard TiddlyWiki.
At the current point in the development process, there is a robust SQL schema that models the recipes/bags/tiddlers/fields of the system. There are efficient queries for simple operations like saving and retrieving a tiddler/bag/recipe, and for enumerating the tiddlers in a bag/recipe. In the future I want to develop the SQL interface much further, ultimately compiling TiddlyWiki filter expressions dynamically into SQL queries.
I have not yet done any work on optimising performance, being focussed on proving the correctness of the design through extensive tests, but I expect performance to be much better than with the existing implementation.
Any questions and comments welcome.