explain.depesz.com

PostgreSQL's explain analyze made readable

Result: q8MY

Settings
# exclusive inclusive rows x rows loops node
1. 0.043 0.975 ↓ 2.9 26 1

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

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

CTE cte_user_preferences

3. 0.010 0.253 ↓ 2.1 17 1

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

4. 0.049 0.049 ↑ 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.048..0.049 rows=1 loops=1)

  • Index Cond: ((cid = 235) AND (id = 199,721))
  • Heap Fetches: 1
5. 0.194 0.194 ↓ 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.074..0.194 rows=17 loops=1)

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

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

7. 0.276 0.276 ↓ 2.1 17 1

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

8. 0.003 0.649 ↓ 9.0 9 1

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

9. 0.022 0.646 ↓ 9.0 9 1

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

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

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

11. 0.021 0.553 ↓ 9.0 9 1

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

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

Sort (cost=19.90..19.90 rows=1 width=35) (actual time=0.487..0.489 rows=9 loops=1)

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

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

  • Hash Cond: (cgp.company_group_id = cug.company_group_id)
14. 0.287 0.287 ↓ 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.082..0.287 rows=340 loops=1)

  • Index Cond: (cid = 235)
15. 0.007 0.067 ↑ 1.0 1 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
16. 0.060 0.060 ↑ 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.059..0.060 rows=1 loops=1)

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

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

  • Sort Key: cup_temp.key
  • Sort Method: quicksort Memory: 26kB
18. 0.010 0.010 ↓ 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.010 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