QUERY PLAN
GroupAggregate (cost=2353.88..2361.96 rows=330 width=44)
Group Key: c.project_id
-> Sort (cost=2353.88..2354.87 rows=395 width=20)
Sort Key: c.project_id
-> Hash Right Join (cost=2151.25..2336.85 rows=395 width=20)
Hash Cond: (tbl_implement_records.case_id = c.id)
-> HashAggregate (cost=410.51..511.28 rows=6718 width=20)
Group Key: tbl_implement_records.case_id
-> Seq Scan on tbl_implement_records (cost=0.00..340.28 rows=7023 width=24)
Filter: (NOT is_draft)
-> Hash (cost=1735.81..1735.81 rows=395 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..1735.81 rows=395 width=8)
Filter: ((case_type = 2) AND (project_id = ANY ('{4175,4174,4173,4172,4171,4170,4169,4168,4167,4166,4164,4161,4158,4157,4155,4152,4151,4150,4144,4142,4127,4111,4098,4096,4086,4079,4078,4063,4057,4052,4014,3991,3950,3949,3927,3899,3886,3874,3872,3857,3855,3816,3813,3786,3767,3764,3760,3752,3751,3744,3723,3714,3686,3679,3661,3660,3653,3652,3644,3633,3623,3599,3591,3590,3589,3577,3576,3568,3552,3544,3515,3514,3513,3503,3467,3458,3441,3424,3372,3371,3318,3300,3281,3276,3274,3269,3265,3263,3251,3246,3235,3225,3216,3209,3208,3201,3195,3157,3148,3073,3027,3019,2939,2907,2893,2759,2695,2684,2530,2508,2507,2504,2459,2458,2422,2080,2079,1983,1963,1938,1929,1925,1791,1460,1240,1111,1018,986,983,887,884,883,861,778,764,88}'::integer[])))