Sqllite | Hackaday
You may be wondering what is the best way to get an unsecured loan? In the past the business owners were stifled by the sluggishness of traditional banks, particularly after the financial crisis, changes have occurred. There is no longer having to wait for weeks or more for a decision regarding your loan application from your local bank. This is a great thing, as waiting for this long could seriously stifle the professionalism of business owners trying to achieve certain objectives like this loan hack.
The rise of lenders online has allowed them to understand how to get a small business loan much simpler. They have made it easier to gain access to capital and accelerated approval times, so that you could be on the way to getting a loan for your business in just a few hours. Flexible business loans can be beneficial in the event of an unplanned or unintentional expense but not have you to take a lower rate than optimal terms or to give up equity to investors.
Love it or hate it, the capabilities of your modern web browser are continually increasing in weird and savage ways. The ability of web applications to run offline requires a persistent local storage solution and for many IndexedDB is the only choice as it works on most browsers and provides a database-like interface. However, as [James Long] Found, IndexedDB is painfully slow on Chrome and limited in query capacity. He decided to bring a tool he was familiar with, SQLite, and integrate it into the web browser as nonsense-sql.
Why absurd? Partly because most browsers (not Chrome) implement IndexedDB on top of SQLite. So for many browsers this is just SQLite on top of IndexedDB on top of SQLite. Luckily for [James] there was already a project known as sql.js which uses emscripten to compile C-based SQLite into WebAssembly. However, sql.js uses in-memory storage media and all data is lost when refreshing the page. [James] fine-tuned SQLite’s block reading and writing method. Instead of being saved in memory, it added a layer to read and write blocks from IndexedDB. This means that only sections of the database need to be read, resulting in huge performance gains.
This brings us to the other reason why this is absurd. On chrome (as well as Firefox), absurd-sql beats IndexedDB on almost all benchmarks. A query like SELECT SUM(*) FROM kv
leads to amazing results.
So what’s the downside? Other than a fairly large WebAssembly file that needs to be downloaded (409KB) and cached, there really isn’t one. Of course, not all is rosy when it comes to web development. Native SQLite runs 2-3 times faster than absurd-sql, which shows how slow IndexedDB really is.
There are other storage standards on the horizon for web browsers, but locking is becoming an issue. SQLite expects synchronous reads and writes because it is just C. IndexedDB and other storage solutions are asynchronous because JavaScript’s event loop lends itself well to this model. Absurd-sql gets around this by creating a SharedArrayBuffer which is shared with a worker process. The atomic API is used to communicate with the buffer. Specifically, atomics.wait()
allows the worker to block the execution of the main thread until the read or write is complete. From SQLite’s point of view, the operations are synchronous. IndexedDB provides transactions so that multiple connections can occur (for example, multiple open tabs). Multiple read-only transactions can occur in parallel, but only one read-write transaction can be in progress.
Why not open up your browser and start playing with it? You’re already doomed to learn WebAssembly anyway.