explain.depesz.com

PostgreSQL's explain analyze made readable

Result: e7Ed

Settings
# exclusive inclusive rows x rows loops node
1. 0.038 0.608 ↓ 2.9 26 1

HashAggregate (cost=34.34..34.43 rows=9 width=178) (actual time=0.601..0.608 rows=26 loops=1)

  • Group Key: cup.key, cup.value
2.          

CTE cte_user_preferences

3. 0.010 0.075 ↓ 2.1 17 1

Nested Loop (cost=0.83..11.34 rows=8 width=39) (actual time=0.040..0.075 rows=17 loops=1)

4. 0.021 0.021 ↑ 1.0 1 1

Index Only Scan using pk_company_users on company_users cu_1 (cost=0.42..2.44 rows=1 width=8) (actual time=0.020..0.021 rows=1 loops=1)

  • Index Cond: ((cid = 235) AND (id = 199,721))
  • Heap Fetches: 1
5. 0.044 0.044 ↓ 2.1 17 1

Index Scan using uk_company_user_preferences_cid_company_user_id_key on company_user_preferences cup_1 (cost=0.41..8.82 rows=8 width=39) (actual time=0.018..0.044 rows=17 loops=1)

  • Index Cond: ((cid = 235) AND (company_user_id = 199,721))
6. 0.006 0.570 ↓ 2.9 26 1

Append (cost=0.00..22.95 rows=9 width=178) (actual time=0.044..0.570 rows=26 loops=1)

7. 0.096 0.096 ↓ 2.1 17 1

CTE Scan on cte_user_preferences cup (cost=0.00..0.16 rows=8 width=178) (actual time=0.043..0.096 rows=17 loops=1)

8. 0.004 0.468 ↓ 9.0 9 1

Subquery Scan on "*SELECT* 2" (cost=20.60..22.71 rows=1 width=57) (actual time=0.384..0.468 rows=9 loops=1)

9. 0.024 0.464 ↓ 9.0 9 1

GroupAggregate (cost=20.60..22.70 rows=1 width=65) (actual time=0.383..0.464 rows=9 loops=1)

  • Group Key: cu.id, cu.cid, cgp.key
10. 0.010 0.440 ↓ 9.0 9 1

Nested Loop (cost=20.60..22.68 rows=1 width=35) (actual time=0.366..0.440 rows=9 loops=1)

11. 0.018 0.367 ↓ 9.0 9 1

Merge Anti Join (cost=20.18..20.23 rows=1 width=35) (actual time=0.352..0.367 rows=9 loops=1)

  • Merge Cond: ((cgp.key)::text = (cup_temp.key)::text)
12. 0.028 0.300 ↓ 9.0 9 1

Sort (cost=19.90..19.90 rows=1 width=35) (actual time=0.299..0.300 rows=9 loops=1)

  • Sort Key: cgp.key
  • Sort Method: quicksort Memory: 25kB
13. 0.087 0.272 ↓ 9.0 9 1

Hash Join (cost=2.60..19.89 rows=1 width=35) (actual time=0.066..0.272 rows=9 loops=1)

  • Hash Cond: (cgp.company_group_id = cug.company_group_id)
14. 0.167 0.167 ↓ 1.0 340 1

Index Scan using pk_company_group_preferences on company_group_preferences cgp (cost=0.28..16.68 rows=332 width=35) (actual time=0.028..0.167 rows=340 loops=1)

  • Index Cond: (cid = 235)
15. 0.002 0.018 ↑ 1.0 1 1

Hash (cost=2.31..2.31 rows=1 width=12) (actual time=0.018..0.018 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
16. 0.016 0.016 ↑ 1.0 1 1

Index Only Scan using uk_company_user_groups_cid_company_user_id_company_group_id on company_user_groups cug (cost=0.29..2.31 rows=1 width=12) (actual time=0.015..0.016 rows=1 loops=1)

  • Index Cond: ((cid = 235) AND (company_user_id = 199,721))
  • Heap Fetches: 1
17. 0.042 0.049 ↑ 2.7 3 1

Sort (cost=0.28..0.30 rows=8 width=146) (actual time=0.048..0.049 rows=3 loops=1)

  • Sort Key: cup_temp.key
  • Sort Method: quicksort Memory: 26kB
18. 0.007 0.007 ↓ 2.1 17 1

CTE Scan on cte_user_preferences cup_temp (cost=0.00..0.16 rows=8 width=146) (actual time=0.001..0.007 rows=17 loops=1)

19. 0.063 0.063 ↑ 1.0 1 9

Index Only Scan using pk_company_users on company_users cu (cost=0.42..2.44 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=9)

  • Index Cond: ((cid = 235) AND (id = 199,721))
  • Heap Fetches: 9