explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 9idN

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

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

  • Buffers: shared hit=370
2.          

CTE _author

3. 0.009 0.009 ↑ 1.0 1 1

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

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

CTE _commenters

5. 0.003 0.048 ↑ 1.0 20 1

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

  • Buffers: shared hit=85
6. 0.013 0.045 ↑ 132.1 20 1

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

  • Buffers: shared hit=85
7. 0.012 0.012 ↑ 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.010..0.012 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.321 ↑ 1.0 20 1

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

  • Buffers: shared hit=91
11. 0.021 0.318 ↑ 31.4 20 1

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

  • Buffers: shared hit=91
12. 0.072 0.253 ↑ 42.0 22 1

Bitmap Heap Scan on user_connection uc (cost=47.16..3,238.19 rows=924 width=8) (actual time=0.247..0.253 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.181 0.181 ↑ 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.181..0.181 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.132 ↑ 1.0 20 1

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

  • Buffers: shared hit=107
17. 0.003 0.129 ↑ 217.1 20 1

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

  • Buffers: shared hit=107
18. 0.038 0.038 ↑ 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.015..0.038 rows=22 loops=1)

  • Index Cond: (group_id = 8,401)
  • Buffers: shared hit=24
19. 0.088 0.088 ↑ 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.004..0.004 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.605 ↑ 1.0 20 1

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

  • Buffers: shared hit=287
22. 0.010 0.601 ↑ 3.0 20 1

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

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

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

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

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

  • Buffers: shared hit=287
25. 0.027 0.426 ↑ 1.9 22 1

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

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

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

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

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

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

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

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

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

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

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

  • Buffers: shared hit=107
31.          

CTE _result

32. 0.002 0.651 ↑ 1.0 20 1

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

  • Buffers: shared hit=287
33. 0.008 0.649 ↑ 2.0 20 1

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

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

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

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

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

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

CTE Scan on _preferred_users (cost=0.00..0.40 rows=20 width=12) (actual time=0.601..0.619 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.026 0.892 ↓ 1.2 20 1

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

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

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

  • Buffers: shared hit=370
40. 0.077 0.813 ↓ 1.2 20 1

Nested Loop Anti Join (cost=0.29..9.97 rows=16 width=12) (actual time=0.676..0.813 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.656 0.656 ↑ 1.0 20 1

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

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

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

  • Buffers: shared hit=3
43. 0.013 0.013 ↓ 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.008..0.013 rows=60 loops=1)

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

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

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