QUERY PLAN
Sort (cost=22.05..22.10 rows=20 width=10)
Sort Key: d."order"
-> HashAggregate (cost=21.42..21.62 rows=20 width=10)
Group Key: u.id, d.id
-> Hash Left Join (cost=1.20..21.32 rows=20 width=10)
Hash Cond: (u.department_id = d.id)
-> Seq Scan on tbl_users u (cost=0.00..20.04 rows=20 width=8)
Filter: (id = ANY ('{1000,1001,1004,1005,1011,1013,1015,1022,1023,5016,5064,5085,5248,5250,5252,5295,5300,5360,5446,5476}'::integer[]))
-> Hash (cost=1.09..1.09 rows=9 width=6)
-> Seq Scan on tbl_departments d (cost=0.00..1.09 rows=9 width=6)