foo=# explain analyze select count(*) from c where tab_id = 2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=14.15..14.16 rows=1 width=0) (actual time=0.070..0.071 rows=1 loops=1) -> Nested Loop (cost=0.00..14.14 rows=1 width=0) (actual time=0.048..0.053 rows=1 loops=1) -> Nested Loop (cost=0.00..9.86 rows=1 width=24) (actual time=0.042..0.045 rows=1 loops=1) -> Nested Loop (cost=0.00..9.58 rows=1 width=32) (actual time=0.038..0.040 rows=1 loops=1) -> Nested Loop (cost=0.00..5.30 rows=1 width=24) (actual time=0.030..0.032 rows=1 loops=1) -> Seq Scan on collection (cost=0.00..1.01 rows=1 width=8) (actual time=0.011..0.012 rows=1 loops=1) Filter: (tab_id = 2) -> Index Scan using perms_pkey on perms (cost=0.00..4.27 rows=1 width=16) (actual time=0.016..0.016 rows=1 loops=1) Index Cond: (perms.item_id = collection.id) Filter: (NOT perms.deleted) -> Index Scan using item_pkey on item (cost=0.00..4.27 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=1) Index Cond: (item.id = perms.item_id) -> Index Scan using user_pkey on "user" (cost=0.00..0.27 rows=1 width=8) (actual time=0.003..0.004 rows=1 loops=1) Index Cond: ("user".id = perms.owner_id) -> Index Scan using folder_pkey on folder (cost=0.00..4.27 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=1) Index Cond: (folder.id = perms.item_id) Total runtime: 0.296 ms (17 rows)