explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 7jCO

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 1.150 ↓ 1.2 20 1

Limit (cost=875.34..875.38 rows=16 width=359) (actual time=1.145..1.150 rows=20 loops=1)

  • Buffers: shared hit=370
2.          

CTE _author

3. 0.012 0.012 ↑ 1.0 1 1

Index Scan using post_pkey on post p (cost=0.42..8.44 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=1)

  • Index Cond: (id = 758,082)
  • Buffers: shared hit=4
4.          

CTE _commenters

5. 0.003 0.053 ↑ 1.0 20 1

Limit (cost=0.86..150.01 rows=20 width=4) (actual time=0.023..0.053 rows=20 loops=1)

  • Buffers: shared hit=85
6. 0.014 0.050 ↑ 132.1 20 1

Nested Loop (cost=0.86..19,696.32 rows=2,641 width=4) (actual time=0.022..0.050 rows=20 loops=1)

  • Buffers: shared hit=85
7. 0.016 0.016 ↑ 194.2 20 1

Index Only Scan using index_comment_on_post_id_and_author_id on comment c (cost=0.43..148.38 rows=3,883 width=4) (actual time=0.014..0.016 rows=20 loops=1)

  • Index Cond: (post_id = 758,082)
  • Heap Fetches: 0
  • Buffers: shared hit=4
8. 0.020 0.020 ↑ 1.0 1 20

Index Only Scan using index_users_active on users u (cost=0.42..5.03 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=20)

  • Index Cond: (id = c.author_id)
  • Filter: (id <> 8)
  • Heap Fetches: 20
  • Buffers: shared hit=81
9.          

CTE _connections

10. 0.003 0.334 ↑ 1.0 20 1

Limit (cost=47.59..332.03 rows=20 width=4) (actual time=0.282..0.334 rows=20 loops=1)

  • Buffers: shared hit=91
11. 0.007 0.331 ↑ 31.4 20 1

Nested Loop (cost=47.59..8,978.94 rows=628 width=4) (actual time=0.281..0.331 rows=20 loops=1)

  • Buffers: shared hit=91
12. 0.078 0.280 ↑ 42.0 22 1

Bitmap Heap Scan on user_connection uc (cost=47.16..3,238.19 rows=924 width=8) (actual time=0.275..0.280 rows=22 loops=1)

  • Recheck Cond: ('{8}'::integer[] <@ ARRAY[user_a_id, user_b_id])
  • Heap Blocks: exact=1
  • Buffers: shared hit=10
13. 0.202 0.202 ↑ 1.0 887 1

Bitmap Index Scan on "index_user_connection_on_ARRAY_user_a_id_user_b_id_gin__int_ops" (cost=0.00..46.93 rows=924 width=0) (actual time=0.202..0.202 rows=887 loops=1)

  • Index Cond: ('{8}'::integer[] <@ ARRAY[user_a_id, user_b_id])
  • Buffers: shared hit=9
14. 0.044 0.044 ↑ 1.0 1 22

Index Only Scan using index_users_active on users u_1 (cost=0.43..6.21 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=22)

  • Index Cond: (id = CASE WHEN (uc.user_a_id = 8) THEN uc.user_b_id ELSE uc.user_a_id END)
  • Heap Fetches: 14
  • Buffers: shared hit=81
15.          

CTE _group_members

16. 0.003 0.332 ↑ 1.0 20 1

Limit (cost=0.85..230.68 rows=20 width=8) (actual time=0.019..0.332 rows=20 loops=1)

  • Buffers: shared hit=107
17. 0.009 0.329 ↑ 217.1 20 1

Nested Loop (cost=0.85..49,896.76 rows=4,342 width=8) (actual time=0.018..0.329 rows=20 loops=1)

  • Buffers: shared hit=107
18. 0.034 0.034 ↑ 290.2 22 1

Index Scan using index_pages_group_memberships_on_group_id_and_created_at on pages_group_memberships pgm (cost=0.43..22,123.88 rows=6,384 width=8) (actual time=0.010..0.034 rows=22 loops=1)

  • Index Cond: (group_id = 8,401)
  • Buffers: shared hit=24
19. 0.286 0.286 ↑ 1.0 1 22

Index Only Scan using index_users_active on users u_2 (cost=0.42..4.35 rows=1 width=4) (actual time=0.013..0.013 rows=1 loops=22)

  • Index Cond: (id = pgm.user_id)
  • Filter: (id <> 8)
  • Heap Fetches: 16
  • Buffers: shared hit=83
20.          

CTE _preferred_users

21. 0.004 0.813 ↑ 1.0 20 1

Limit (cost=5.60..5.65 rows=20 width=12) (actual time=0.808..0.813 rows=20 loops=1)

  • Buffers: shared hit=287
22. 0.011 0.809 ↑ 3.0 20 1

Sort (cost=5.60..5.75 rows=61 width=12) (actual time=0.808..0.809 rows=20 loops=1)

  • Sort Key: (0)
  • Sort Method: top-N heapsort Memory: 26kB
  • Buffers: shared hit=287
23. 0.019 0.798 ↑ 1.5 42 1

HashAggregate (cost=3.36..3.97 rows=61 width=12) (actual time=0.792..0.798 rows=42 loops=1)

  • Group Key: ((_author.id)::bigint), (0)
  • Buffers: shared hit=287
24. 0.005 0.779 ↑ 1.5 42 1

Append (cost=1.64..3.06 rows=61 width=12) (actual time=0.431..0.779 rows=42 loops=1)

  • Buffers: shared hit=287
25. 0.015 0.434 ↑ 1.9 22 1

HashAggregate (cost=1.64..2.15 rows=41 width=12) (actual time=0.430..0.434 rows=22 loops=1)

  • Group Key: _author.id, (0)
  • Buffers: shared hit=180
26. 0.006 0.419 ↑ 1.0 41 1

Append (cost=0.00..1.44 rows=41 width=8) (actual time=0.014..0.419 rows=41 loops=1)

  • Buffers: shared hit=180
27. 0.014 0.014 ↑ 1.0 1 1

CTE Scan on _author (cost=0.00..0.02 rows=1 width=8) (actual time=0.013..0.014 rows=1 loops=1)

  • Buffers: shared hit=4
28. 0.059 0.059 ↑ 1.0 20 1

CTE Scan on _commenters (cost=0.00..0.40 rows=20 width=8) (actual time=0.024..0.059 rows=20 loops=1)

  • Buffers: shared hit=85
29. 0.340 0.340 ↑ 1.0 20 1

CTE Scan on _connections (cost=0.00..0.40 rows=20 width=8) (actual time=0.283..0.340 rows=20 loops=1)

  • Buffers: shared hit=91
30. 0.340 0.340 ↑ 1.0 20 1

CTE Scan on _group_members (cost=0.00..0.40 rows=20 width=12) (actual time=0.020..0.340 rows=20 loops=1)

  • Buffers: shared hit=107
31.          

CTE _result

32. 0.003 0.851 ↑ 1.0 20 1

Limit (cost=3.06..3.11 rows=20 width=12) (actual time=0.847..0.851 rows=20 loops=1)

  • Buffers: shared hit=287
33. 0.009 0.848 ↑ 2.0 20 1

Sort (cost=3.06..3.16 rows=40 width=12) (actual time=0.847..0.848 rows=20 loops=1)

  • Sort Key: _preferred_users.source_order
  • Sort Method: quicksort Memory: 26kB
  • Buffers: shared hit=287
34. 0.016 0.839 ↑ 1.0 40 1

HashAggregate (cost=1.60..2.00 rows=40 width=12) (actual time=0.833..0.839 rows=40 loops=1)

  • Group Key: _preferred_users.id, _preferred_users.source_order
  • Buffers: shared hit=287
35. 0.003 0.823 ↑ 1.0 40 1

Append (cost=0.00..1.40 rows=40 width=12) (actual time=0.809..0.823 rows=40 loops=1)

  • Buffers: shared hit=287
36. 0.817 0.817 ↑ 1.0 20 1

CTE Scan on _preferred_users (cost=0.00..0.40 rows=20 width=12) (actual time=0.809..0.817 rows=20 loops=1)

  • Buffers: shared hit=287
37. 0.003 0.003 ↑ 1.0 20 1

CTE Scan on _preferred_users _preferred_users_1 (cost=0.00..0.40 rows=20 width=12) (actual time=0.001..0.003 rows=20 loops=1)

38. 0.025 1.146 ↓ 1.2 20 1

Sort (cost=145.41..145.45 rows=16 width=359) (actual time=1.144..1.146 rows=20 loops=1)

  • Sort Key: _result.source_order
  • Sort Method: quicksort Memory: 30kB
  • Buffers: shared hit=370
39. 0.008 1.121 ↓ 1.2 20 1

Nested Loop (cost=0.72..145.09 rows=16 width=359) (actual time=0.888..1.121 rows=20 loops=1)

  • Buffers: shared hit=370
40. 0.116 1.053 ↓ 1.2 20 1

Nested Loop Anti Join (cost=0.29..9.97 rows=16 width=12) (actual time=0.877..1.053 rows=20 loops=1)

  • Join Filter: (user_event_blocks.suggested_user_id = _result.id)
  • Rows Removed by Join Filter: 1,200
  • Buffers: shared hit=290
41. 0.857 0.857 ↑ 1.0 20 1

CTE Scan on _result (cost=0.00..0.40 rows=20 width=12) (actual time=0.848..0.857 rows=20 loops=1)

  • Buffers: shared hit=287
42. 0.066 0.080 ↓ 15.0 60 20

Materialize (cost=0.29..8.38 rows=4 width=4) (actual time=0.001..0.004 rows=60 loops=20)

  • Buffers: shared hit=3
43. 0.014 0.014 ↓ 15.0 60 1

Index Only Scan using index_user_event_blocks_on_user_id_and_suggested_user_id on user_event_blocks (cost=0.29..8.36 rows=4 width=4) (actual time=0.009..0.014 rows=60 loops=1)

  • Index Cond: (user_id = 8)
  • Heap Fetches: 0
  • Buffers: shared hit=3
44. 0.060 0.060 ↑ 1.0 1 20

Index Scan using users_pkey on users (cost=0.43..8.45 rows=1 width=355) (actual time=0.003..0.003 rows=1 loops=20)

  • Index Cond: (id = _result.id)
  • Buffers: shared hit=80
Planning time : 1.907 ms
Execution time : 1.314 ms