High Performance
SQLite
Introduction
Introduction to this course
Introduction to SQLite
SQLite is safe
It's just a file
Running SQLite locally
Good uses for SQLite
SQLite's limitations
The documentation
SQLite Internals
SQLite's structure
SQLite's file format
Dot commands
Pragmas
Virtual tables
Schema
Flexible types
Types
Strict types
Dates
Booleans
Floating point
Rowid tables
Auto increments
Without rowid
Generated columns
Optimizing SQLite
Locking
Rollback mode
WAL mode
WAL vs Journal benchmarks
Busy timeout
Transaction modes
Vacuum
Analyze & Optimize
Suggested pragmas
Faster inserts
Indexes
Introduction to indexes
B+ trees
Primary, secondary, and clustered indexes
Without rowid tables
Benchmarking without rowid tables
Imposter tables
Primary key data types
Where to add indexes
Index selectivity
Composite indexes
Composite ordering
Covering indexes
Partial indexes
Indexes on expressions
Automatic indexes
Duplicate indexes
Indexing joins
Advanced SQL
Explain
Index obfuscation
Joins
Subqueries
Unions
CTEs
Recursive CTEs
Window functions
Dealing with NULLs
Row value syntax
Indexed sorting
Upserts
Returning
Aggregates
Triggers
Operating SQLite
Altering schema
Altering schema with tools
Multi-database
Multi-tenancy
Backups
Exports
How to corrupt SQLite
Advanced JSON
Intro to JSON
JSON vs. JSONB
Argument types: path, value, JSON
JSON5
Valid JSON
Creating JSON objects + arrays
JSON Extraction
Updating JSON
JSON aggregates
JSON table functions
Indexing JSON
Full Text Search
Creating FTS tables
Performing searches
Ranking results
Highlighting matches
Bonus Interviews
DHH discusses SQLite in Ruby on Rails
Distributed SQLite with Litestream and LiteFS
Offline-first, multiplayer SQLite
Production SQLite with Turso and libSQL
Migrating from Postgres to SQLite with Kent C. Dodds
Ruby on Rails with SQLite
Moving from Redis to SQLite with Mike Buckbee
Next video (8)
Introduction
It's just a file

Full Course

$
179
$229
USD, one-time fee
High Performance SQLite is an excellent and immersive course, featuring real-time typed commands and valuable edge case explanations. I highly recommend it for enhancing your SQLite skills.
Han-Hsun Liu
Han-Hsun Liu

SQLite for Production

Build with and integrate SQLite into your production applications.

Test Data

I've made my test data available for you to use and follow along.

Download
or
Use on Turso

Summary

A SQLite database is simply a file on disk, making it highly cross-platform and ideal for easy data distribution and broad compatibility. Its strong backward compatibility and minimal overhead make it a great choice for testing environments and multi-database setups. While using a single file does require a non-ephemeral disk, the overall flexibility and convenience often make it the preferred solution.

Video Transcript

I told you that a SQLite database is just a file on disk, which is very different than how MySQL and Postgres works. But is it better? I don't know. I'm not interested in absolute pronouncements. I will tell you about the file and we can decide together if it's good for your use case.

This file, very, very strictly defined format. That's one of its great strengths is its file format is very rigid and very well known. It has great backwards compatibility and you can trust that it has forwards compatibility. If you put all of your data into this SQLite database file, the odds are nearing 100% that every computing platform will be able to read the data in that file. Extremely cross platform, cross architecture, cross everything.

That's one of the great strengths is if you put your data in this file, you can distribute it very easily. This makes it really nice for sending out data sets to clients, whether that's a front end or a mobile device or a desktop device or just other servers somewhere. It makes a nice, data packaging format. The other thing is that future compatibility. You know that you're pretty safe storing your data in a SQLite file because of their insane commitment to backwards compatibility and the fact that if it's good enough for the Library of Congress in the US, it's probably good enough for my web application, mobile desktop application, whatever it is.

The other thing is there's no overhead for creating a new database. If you wanna go multi database, multi tenant, which we'll talk about later, that's great. If you wanna create a new database for each service, so maybe you have a database to store like your actual data and then one to run your queues and one to serve as a cache back end, that's great. You can do that. That's just 3 separate files at that point.

The fact that it's a file I think is a benefit in a lot of situations. It can be a drawback because the file has to live on a disk that's not ephemeral. You can't have, you can't have it living on a serverless disk. Right? You can't have it in Lambda because that Lambda's gonna go away eventually.

There are ways around that, with with things like Turso, honestly. But we'll look at that as we move forward. That is a drawback of it being a single file. I think one of the final things that the low overhead file only approach allows for is it's great for testing. So when you're running your CI or CD, it makes it very easy to use SQLite just like you do in production.

In fact, at that point it doesn't even have to be a file. You can just load the data into memory and SQLite can deal with it there. Instead of having to run MySQL locally, MySQL in CICD and MySQL in production, You can just use SQLite and the the the barrier to entry is a lot lower and it makes your tests a lot faster and a lot more compatible with production which is what we're always after. So just a single file, pretty cool honestly. It has some drawbacks but it opens up a lot of use cases which we'll continue to cover throughout this course.