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
SQLite is safe

Full Course

$
179
$229
USD, one-time fee
Thank you for the excellent High Performance SQLite course! It’s been incredibly useful in deepening my understanding of SQLite. The sections on SQLite internals, schema, and optimization techniques are particularly insightful and have significantly improved my ability to work with SQLite in production environments.
Ali Kasmani
Ali Kasmani

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

SQLite stands out for its safety and reliability, originally designed to handle challenging environments like power failures on mobile devices. Its strict development model—accepting no outside contributions—helps preserve stability and strong database guarantees. For those seeking a more open development path, Turso’s libSQL offers a community-friendly fork of SQLite with plans to eventually merge back upstream.

Video Transcript

One of the great things about SQLite, and there are so many great things, but one of them is that it's incredibly safe. It's incredibly safe and robust, and it gives you these strong guarantees that you would expect out of a database. We owe a lot of that to its history of operating in pretty hostile environments. I don't necessarily mean hostile like battlefield, although I think SQLite was written for a battleship, so maybe kind of. I mean hostile like your cell phone because the battery could die at any moment up to and including in the middle of a transaction.

SQLite has operated on mobile devices since the very beginning. That's one of its great strengths is it's an embedded database and so it goes great on mobile devices. Mobile devices have batteries and they used to have media, storage media that could just be removed at any moment. SQLite has to be resilient to power failures and the media completely disappearing. And so they have 600 lines of test code for every single line of library code.

That's a lot. Do I wanna do that? No way. No way I'm gonna write that mini test. Do I want my database to be that tested?

Yeah. I super duper do. They have these custom file systems that simulate power outages or media being removed. They have fuzz tests to test every single thing you could think of and that's because they have this commitment to maintain backwards compatibility and future proof it through 2050 at the very earliest. That's that's their commitment so far.

They may push it. That leads us to 1, a little sticky wicket. I don't know if it's a problem, but it's a little bit it's a little bit weird. They say that they're open source, not open contribution. That sounds strange.

Right? The source is available. You can go look at it. You can go read it. You there's no copyright whatsoever.

You can take it and do whatever you want with it, but they do not accept contributions from outsiders. One of the things or one of the reasons that they don't accept contributions is for this high reliability, high stability. They they claim that to keep it as reliable and stable as it is, very very few people can work on it, and they just don't accept pull requests from the outside world. I'm not here to make a judgment on if that's right or wrong. That's just what they say.

There is a fork that is open contribution and that's libSQL or lib SQL, and that's maintained by the Turso team. It is a fork of SQLite with a few things added that is open contribution slash open source. Their goal is to merge them back together, but that would take SQLite changing its stance on contributions. So SQLite is incredibly reliable, incredibly safe, strong ACID guarantees just like every other database, a transaction is not going to be half committed. It's all or nothing, even if the power goes out and that gives me great comfort.