QUERY PLAN
GroupAggregate (cost=49.87..50.03 rows=9 width=48)
Group Key: dg.id
-> Sort (cost=49.87..49.89 rows=9 width=286)
Sort Key: dg.id
-> Nested Loop Left Join (cost=33.38..49.73 rows=9 width=286)
-> Hash Join (cost=33.24..44.94 rows=9 width=12)
Hash Cond: (d.id = vd.document_id)
-> Seq Scan on tbl_documents d (cost=0.00..11.20 rows=120 width=16)
-> Hash (cost=33.12..33.12 rows=9 width=4)
-> Seq Scan on tbl_visible_documents vd (cost=0.00..33.12 rows=9 width=4)
Filter: (accessible_user = 5495)
-> Index Scan using tbl_document_types_pkey on tbl_document_types dg (cost=0.15..0.53 rows=1 width=278)
Index Cond: (d.document_type_id = id)