QUERY PLAN
HashAggregate (cost=16.88..16.97 rows=9 width=158)
Group Key: dd.id
-> Hash Join (cost=1.20..14.84 rows=407 width=158)
Hash Cond: (d.department_id = dd.id)
-> Seq Scan on tbl_documents d (cost=0.00..12.07 rows=407 width=16)
-> Hash (cost=1.09..1.09 rows=9 width=150)
-> Seq Scan on tbl_departments dd (cost=0.00..1.09 rows=9 width=150)
Filter: (id IS NOT NULL)