by Markus Winand.

SQLite Execution Plan Operations


A short reference of the most common SQLite execution plan operations. The respective product documentation is here.

Index and Table Access

SCAN TABLE …

Reads the entire table.

SEARCH TABLE … USING INDEX

Traverses an index tree, follows the leaf node list and fetches the corresponding data from the table.

SEARCH TABLE … USING COVERING INDEX

Traverses an index tree and follows the leaf node list to fetch all matching rows (aka. Index Only Scan).

Joins

Generally join operations process only two tables at a time. In case a query has more joins, they are executed sequentially: first two tables, then the intermediate result with the next table. In the context of joins, the term “table” could therefore also mean “intermediate result”.

SQLite supports only nested loops joins. The query plan starts by showing the outermost table access, followed by each nested access (similar to MySQL/MariaDB).

Nesting in the query plan output doesn’t indicated joins but nested queries (including union, except, intersect).

Sorting and Grouping

SQLite always needs an index for order by, group by and distinct. If no suitable index exists in the system prior to query evaluation, a temporary index is created.

USE TEMP B-TREE FOR …

Indicates that a temporary index was created to perform the specified operation.

Top-N Queries

The effect of a limit clause is not visible in the explain query plan output. In the raw explain output, you can see a LIMIT counter.

About the Author

Photo of Markus Winand

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy his Book

Cover of “SQL Performance Explained”: Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of any size.
Learn more »

Do not use offset for pagination

Learn why

Visit my sibling!A lot changed since SQL-92!

The Use The Index, Luke! mug

Stickers, coasters, books and coffee mugs. All you need for learning.

Shop now

Connect with Markus Winand

Markus Winand on LinkedInMarkus Winand on XINGMarkus Winand on Twitter
“Use The Index, Luke!” by Markus Winand is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR | CC-BY-NC-ND 3.0 license