Back

SQL Details

Executed SQL
EXPLAIN QUERY PLAN
SELECT categories.id AS categories_id, categories.title AS categories_title, categories.description AS categories_description, categories.position AS categories_position, anon_1.id AS anon_1_id, anon_1.category_id AS anon_1_category_id, anon_1.title AS anon_1_title, anon_1.description AS anon_1_description, anon_1.position AS anon_1_position, anon_1.locked AS anon_1_locked, anon_1.show_moderators AS anon_1_show_moderators, anon_1.external AS anon_1_external, anon_1.post_count AS anon_1_post_count, anon_1.topic_count AS anon_1_topic_count, anon_1.last_post_id AS anon_1_last_post_id, anon_1.last_post_title AS anon_1_last_post_title, anon_1.last_post_user_id AS anon_1_last_post_user_id, anon_1.last_post_username AS anon_1_last_post_username, anon_1.last_post_created AS anon_1_last_post_created, users_1.password AS users_1_password, groups_1.id AS groups_1_id, groups_1.name AS groups_1_name, groups_1.description AS groups_1_description, groups_1.admin AS groups_1_admin, groups_1.super_mod AS groups_1_super_mod, groups_1.mod AS groups_1_mod, groups_1.guest AS groups_1_guest, groups_1.banned AS groups_1_banned, groups_1.mod_edituser AS groups_1_mod_edituser, groups_1.mod_banuser AS groups_1_mod_banuser, groups_1.editpost AS groups_1_editpost, groups_1.deletepost AS groups_1_deletepost, groups_1.deletetopic AS groups_1_deletetopic, groups_1.posttopic AS groups_1_posttopic, groups_1.postreply AS groups_1_postreply, users_1.id AS users_1_id, users_1.username AS users_1_username, users_1.email AS users_1_email, users_1.date_joined AS users_1_date_joined, users_1.lastseen AS users_1_lastseen, users_1.birthday AS users_1_birthday, users_1.gender AS users_1_gender, users_1.website AS users_1_website, users_1.location AS users_1_location, users_1.signature AS users_1_signature, users_1.avatar AS users_1_avatar, users_1.notes AS users_1_notes, users_1.last_failed_login AS users_1_last_failed_login, users_1.login_attempts AS users_1_login_attempts, users_1.activated AS users_1_activated, users_1.theme AS users_1_theme, users_1.language AS users_1_language, users_1.post_count AS users_1_post_count, users_1.primary_group_id AS users_1_primary_group_id, groups_2.id AS groups_2_id, groups_2.name AS groups_2_name, groups_2.description AS groups_2_description, groups_2.admin AS groups_2_admin, groups_2.super_mod AS groups_2_super_mod, groups_2.mod AS groups_2_mod, groups_2.guest AS groups_2_guest, groups_2.banned AS groups_2_banned, groups_2.mod_edituser AS groups_2_mod_edituser, groups_2.mod_banuser AS groups_2_mod_banuser, groups_2.editpost AS groups_2_editpost, groups_2.deletepost AS groups_2_deletepost, groups_2.deletetopic AS groups_2_deletetopic, groups_2.posttopic AS groups_2_posttopic, groups_2.postreply AS groups_2_postreply 
FROM categories JOIN (SELECT forums.id AS id, forums.category_id AS category_id, forums.title AS title, forums.description AS description, forums.position AS position, forums.locked AS locked, forums.show_moderators AS show_moderators, forums.external AS external, forums.post_count AS post_count, forums.topic_count AS topic_count, forums.last_post_id AS last_post_id, forums.last_post_title AS last_post_title, forums.last_post_user_id AS last_post_user_id, forums.last_post_username AS last_post_username, forums.last_post_created AS last_post_created 
FROM forums 
WHERE EXISTS (SELECT 1 
FROM forumgroups, groups 
WHERE forumgroups.forum_id = forums.id AND groups.id = forumgroups.group_id AND groups.id = ?)) AS anon_1 ON categories.id = anon_1.category_id LEFT OUTER JOIN (moderators AS moderators_1 JOIN users AS users_1 ON users_1.id = moderators_1.user_id) ON moderators_1.forum_id = anon_1.id LEFT OUTER JOIN groups AS groups_1 ON groups_1.id = users_1.primary_group_id LEFT OUTER JOIN (forumgroups AS forumgroups_1 JOIN groups AS groups_2 ON groups_2.id = forumgroups_1.group_id) ON forumgroups_1.forum_id = anon_1.id ORDER BY categories.position, categories.id, anon_1.position
Original query duration
2.3739 ms
SELECTID ORDER FROM DETAIL
1 0 0 SCAN TABLE moderators AS moderators_1
1 1 1 SEARCH TABLE users AS users_1 USING INTEGER PRIMARY KEY (rowid=?)
2 0 0 SCAN TABLE forumgroups AS forumgroups_1
2 1 1 SEARCH TABLE groups AS groups_2 USING INTEGER PRIMARY KEY (rowid=?)
0 0 1 SCAN TABLE forums
0 0 0 EXECUTE CORRELATED SCALAR SUBQUERY 3
3 0 1 SEARCH TABLE groups USING INTEGER PRIMARY KEY (rowid=?)
3 1 0 SCAN TABLE forumgroups
0 1 0 SEARCH TABLE categories USING INTEGER PRIMARY KEY (rowid=?)
0 2 2 SEARCH SUBQUERY 1 USING AUTOMATIC COVERING INDEX (forum_id=?)
0 3 3 SEARCH TABLE groups AS groups_1 USING INTEGER PRIMARY KEY (rowid=?)
0 4 4 SEARCH SUBQUERY 2 USING AUTOMATIC COVERING INDEX (forum_id=?)
0 0 0 USE TEMP B-TREE FOR ORDER BY