QUERY PLAN
GroupAggregate (cost=1059.27..1060.50 rows=54 width=44)
Group Key: c.project_id
-> Sort (cost=1059.27..1059.41 rows=55 width=20)
Sort Key: c.project_id
-> Hash Right Join (cost=878.91..1057.68 rows=55 width=20)
Hash Cond: (tbl_implement_records.case_id = c.id)
-> HashAggregate (cost=394.56..491.62 rows=6471 width=20)
Group Key: tbl_implement_records.case_id
-> Seq Scan on tbl_implement_records (cost=0.00..326.79 rows=6777 width=24)
Filter: (NOT is_draft)
-> Hash (cost=483.66..483.66 rows=55 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..483.66 rows=55 width=8)
Filter: ((case_type = 2) AND (project_id = ANY ('{3957,4005,3976,4002,3972,4034,4037,4026,4007,3986,4041,4031,4030,4029,4020,4017,4001,3997,3996,3994}'::integer[])))