EXPLAIN QUERY PLAN
noun
say it: “ik-SPLAYN KWEER-ee PLAN” /ɪkˈspleɪn ˈkwɪri plæn/
A SQLite command put in front of a query that shows how the database will run it, such as reading the whole table or using an index, instead of returning rows.
What does EXPLAIN QUERY PLAN show in SQLite?
EXPLAIN QUERY PLAN, put in front of a SQLite query, answers with how the query will run instead of its rows.
SCAN means reading every row of the table; SEARCH ... USING INDEX means jumping straight to the rows through an
index, which stays quick as the table grows.
EXPLAIN QUERY PLAN SELECT * FROM vendors WHERE email = 'hilltop@example.com';
-- SCAN vendors
CREATE INDEX idx_vendors_email ON vendors (email);
EXPLAIN QUERY PLAN SELECT * FROM vendors WHERE email = 'hilltop@example.com';
-- SEARCH vendors USING INDEX idx_vendors_email (email=?)
In a sentence
- “EXPLAIN QUERY PLAN said SCAN vendors, so the email lookup was reading every row.”
- “After the new index, EXPLAIN QUERY PLAN answered SEARCH vendors USING INDEX.”
Level: Freelancer · More SQLite terms at this level
Updated