sqlite> EXPLAIN QUERY PLAN SELECT DISTINCT s.sid, n.value, e.value FROM session AS s LEFT JOIN session_attribute AS n ON (n.sid=s.sid AND n.authenticated=1 AND n.name = 'name') LEFT JOIN session_attribute AS e ON (e.sid=s.sid AND e.authenticated=1 AND e.name = 'email') WHERE s.authenticated=1 ORDER BY s.sid; QUERY PLAN |--SEARCH TABLE session AS s USING INDEX session_authenticated_idx (authenticated=?) |--SEARCH TABLE session_attribute AS n USING INDEX sqlite_autoindex_session_attribute_1 (sid=? AND authenticated=? AND name=?) |--SEARCH TABLE session_attribute AS e USING INDEX sqlite_autoindex_session_attribute_1 (sid=? AND authenticated=? AND name=?) |--USE TEMP B-TREE FOR DISTINCT `--USE TEMP B-TREE FOR ORDER BY