In SQL, when a query is filtered by multiple conditions a simple optimization is to list more restrictive conditions before less restrictive ones, because the conditions are evaluated in first-to-last order.
SELECT _id, col1, col2, col3
FROM table
WHERE
col1 = "most_resctrictive_condition" AND
col2 = "less_resctrictive_condition" AND
col3 = "least_resctrictive_condition"
Question: in SQLite, if a particular column is indexed, does SQLite evaluate the condition on the indexed column first, even if it is listed after other conditions? For instance, if col3
is indexed but the other columns are not, will SQLite evaluate the 3rd condition first as an optimization, or will it always evaluate in the order the conditions appear in the query as it is written?