QUERY PLAN
Limit (cost=306.21..306.22 rows=1 width=239)
InitPlan 1 (returns $0)
-> Aggregate (cost=147.00..147.01 rows=1 width=32)
-> Seq Scan on tbl_tasks s_1 (cost=0.00..144.00 rows=1200 width=13)
Filter: (tree_path IS NOT NULL)
-> Sort (cost=159.20..159.21 rows=1 width=239)
Sort Key: s.status, u.pinyin_shortcut, s.target_completed_at, s.created_at DESC
-> Group (cost=159.18..159.19 rows=1 width=239)
Group Key: s.id, u.pinyin_shortcut
-> Sort (cost=159.18..159.19 rows=1 width=239)
Sort Key: s.id, u.pinyin_shortcut
-> Nested Loop Left Join (cost=0.00..159.17 rows=1 width=239)
Join Filter: (u.id = s.head_of)
-> Seq Scan on tbl_tasks s (cost=0.00..150.00 rows=1 width=236)
Filter: ((parent_id IS NULL) AND (tree_path @> $0) AND (task_group_id = 93))
-> Seq Scan on tbl_users u (cost=0.00..7.41 rows=141 width=7)