QUERY PLAN
HashAggregate (cost=657.48..660.50 rows=302 width=48)
Group Key: tt.id
-> Merge Right Join (cost=285.30..655.33 rows=431 width=24)
Merge Cond: (ttr.object_id = d.id)
-> Nested Loop Left Join (cost=0.44..2145.02 rows=391 width=20)
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships ttr (cost=0.29..2056.59 rows=391 width=8)
Index Cond: (term_id = 7)
-> Index Scan using tbl_term_taxonomies_pkey on tbl_term_taxonomies tt (cost=0.15..0.23 rows=1 width=16)
Index Cond: (ttr.taxonomy_id = id)
-> Sort (cost=279.37..280.45 rows=431 width=12)
Sort Key: d.id
-> Hash Join (cost=17.70..260.51 rows=431 width=12)
Hash Cond: (vd.document_id = d.id)
-> Seq Scan on tbl_visible_documents vd (cost=0.00..241.68 rows=431 width=4)
Filter: (accessible_user = 1011)
-> Hash (cost=12.31..12.31 rows=431 width=16)
-> Seq Scan on tbl_documents d (cost=0.00..12.31 rows=431 width=16)