QUERY PLAN
GroupAggregate (cost=115.68..115.89 rows=12 width=48)
Group Key: tt.id
-> Sort (cost=115.68..115.71 rows=12 width=23)
Sort Key: tt.id
-> Nested Loop Left Join (cost=0.43..115.46 rows=12 width=23)
-> Nested Loop Left Join (cost=0.29..112.93 rows=12 width=12)
-> Seq Scan on tbl_documents d (cost=0.00..13.09 rows=12 width=16)
Filter: (created_by = 1000)
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships ttr (cost=0.29..8.31 rows=1 width=8)
Index Cond: ((object_id = d.id) AND (term_id = 7))
-> Index Scan using tbl_term_taxonomies_pkey on tbl_term_taxonomies tt (cost=0.14..0.21 rows=1 width=15)
Index Cond: (ttr.taxonomy_id = id)