QUERY PLAN
GroupAggregate (cost=0.14..1500.86 rows=1 width=158)
Group Key: dd.id
-> Nested Loop (cost=0.14..1500.84 rows=1 width=158)
Join Filter: (d.department_id = dd.id)
-> Index Scan using tbl_departments_pkey on tbl_departments dd (cost=0.14..12.29 rows=9 width=150)
Index Cond: (id IS NOT NULL)
-> Materialize (cost=0.00..1488.41 rows=1 width=12)
-> Nested Loop (cost=0.00..1488.41 rows=1 width=12)
Join Filter: (d.id = dt.object_id)
-> Seq Scan on tbl_term_taxonomy_relationships dt (cost=0.00..1470.28 rows=1 width=4)
Filter: ((term_id = 7) AND (taxonomy_id = 116))
-> Seq Scan on tbl_documents d (cost=0.00..12.50 rows=450 width=20)