QUERY PLAN
Sort (cost=98.69..98.69 rows=1 width=190)
Sort Key: s.status, s.target_completed_at, s.created_at DESC
InitPlan 1 (returns $0)
-> Aggregate (cost=47.75..47.76 rows=1 width=32)
-> Seq Scan on tbl_tasks s_1 (cost=0.00..44.60 rows=1260 width=13)
Filter: (tree_path IS NOT NULL)
-> Group (cost=50.91..50.92 rows=1 width=190)
Group Key: s.id
-> Sort (cost=50.91..50.91 rows=1 width=190)
Sort Key: s.id
-> Seq Scan on tbl_tasks s (cost=0.00..50.90 rows=1 width=190)
Filter: ((tree_path @> $0) AND (parent_id = 1713))