QUERY PLAN
Sort (cost=98.87..98.88 rows=1 width=196)
Sort Key: s.target_completed_at, s.created_at DESC
InitPlan 1 (returns $0)
-> Aggregate (cost=46.41..46.42 rows=1 width=32)
-> Seq Scan on tbl_tasks s_1 (cost=0.00..46.30 rows=45 width=13)
Filter: ((tree_path IS NOT NULL) AND (status = '0'::smallint))
-> Group (cost=52.43..52.44 rows=1 width=196)
Group Key: s.id
-> Sort (cost=52.43..52.44 rows=1 width=196)
Sort Key: s.id
-> Seq Scan on tbl_tasks s (cost=0.00..52.42 rows=1 width=196)
Filter: ((tree_path @> $0) AND (status = '0'::smallint) AND (parent_id = 1647))