explain.depesz.com

PostgreSQL's explain analyze made readable

Result: yWE8

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 7.784 ↑ 1.0 20 1

Limit (cost=4,268.39..4,268.44 rows=20 width=363) (actual time=7.781..7.784 rows=20 loops=1)

  • Buffers: shared hit=9,131
2.          

CTE _author

3. 0.001 0.023 ↓ 0.0 0 1

Nested Loop (cost=0.85..16.89 rows=1 width=4) (actual time=0.023..0.023 rows=0 loops=1)

  • Buffers: shared hit=8
4. 0.008 0.008 ↑ 1.0 1 1

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

  • Index Cond: (id = 758,082)
  • Buffers: shared hit=4
5. 0.014 0.014 ↓ 0.0 0 1

Index Scan using users_pkey on users u_1 (cost=0.43..8.45 rows=1 width=4) (actual time=0.014..0.014 rows=0 loops=1)

  • Index Cond: (id = p.author_id)
  • Filter: (concat_ws(' '::text, first_name, last_name) ~~* '%Ja%'::text)
  • Rows Removed by Filter: 1
  • Buffers: shared hit=4
6.          

CTE _commenters

7. 0.003 1.624 ↑ 1.0 20 1

Limit (cost=0.86..976.12 rows=20 width=4) (actual time=1.582..1.624 rows=20 loops=1)

  • Buffers: shared hit=3,238
8. 0.000 1.621 ↑ 26.4 20 1

Nested Loop (cost=0.86..25,747.74 rows=528 width=4) (actual time=1.582..1.621 rows=20 loops=1)

  • Buffers: shared hit=3,238
9. 0.124 0.124 ↑ 4.8 815 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.124 rows=815 loops=1)

  • Index Cond: (post_id = 758,082)
  • Heap Fetches: 41
  • Buffers: shared hit=42
10. 1.630 1.630 ↓ 0.0 0 815

Index Scan using index_users_active on users u_2 (cost=0.42..6.59 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=815)

  • Index Cond: (id = c.author_id)
  • Filter: ((id <> 8) AND (concat_ws(' '::text, first_name, last_name) ~~* '%Ja%'::text))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=3,196
11.          

CTE _connections

12. 0.004 3.631 ↑ 1.0 20 1

Limit (cost=51.59..1,707.26 rows=20 width=4) (actual time=0.555..3.631 rows=20 loops=1)

  • Buffers: shared hit=3,698
13. 0.367 3.627 ↑ 6.3 20 1

Nested Loop (cost=51.59..10,482.30 rows=126 width=4) (actual time=0.555..3.627 rows=20 loops=1)

  • Buffers: shared hit=3,698
14. 0.685 0.881 ↑ 1.2 793 1

Bitmap Heap Scan on user_connection uc (cost=51.16..3,242.19 rows=924 width=8) (actual time=0.274..0.881 rows=793 loops=1)

  • Recheck Cond: ('{8}'::integer[] <@ ARRAY[user_a_id, user_b_id])
  • Heap Blocks: exact=592
  • Buffers: shared hit=602
15. 0.196 0.196 ↑ 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..50.93 rows=924 width=0) (actual time=0.196..0.196 rows=887 loops=1)

  • Index Cond: ('{8}'::integer[] <@ ARRAY[user_a_id, user_b_id])
  • Buffers: shared hit=10
16. 2.379 2.379 ↓ 0.0 0 793

Index Scan using index_users_active on users u_3 (cost=0.43..7.84 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=793)

  • Index Cond: (id = CASE WHEN (uc.user_a_id = 8) THEN uc.user_b_id ELSE uc.user_a_id END)
  • Filter: (concat_ws(' '::text, first_name, last_name) ~~* '%Ja%'::text)
  • Rows Removed by Filter: 1
  • Buffers: shared hit=3,096
17.          

CTE _group_members

18. 0.004 2.076 ↑ 1.0 20 1

Limit (cost=0.85..1,378.82 rows=20 width=8) (actual time=0.149..2.076 rows=20 loops=1)

  • Buffers: shared hit=2,066
19. 0.000 2.072 ↑ 42.0 20 1

Nested Loop (cost=0.85..57,875.38 rows=840 width=8) (actual time=0.148..2.072 rows=20 loops=1)

  • Buffers: shared hit=2,066
20. 0.401 0.401 ↑ 14.7 419 1

Index Scan using index_pages_group_memberships_on_group_id on pages_group_memberships pgm (cost=0.43..21,279.28 rows=6,178 width=8) (actual time=0.015..0.401 rows=419 loops=1)

  • Index Cond: (group_id = 8,401)
  • Filter: (status = 'joined'::pages_group_membership_status)
  • Rows Removed by Filter: 12
  • Buffers: shared hit=396
21. 1.676 1.676 ↓ 0.0 0 419

Index Scan using index_users_active on users u_4 (cost=0.42..5.92 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=419)

  • Index Cond: (id = pgm.user_id)
  • Filter: ((id <> 8) AND (concat_ws(' '::text, first_name, last_name) ~~* '%Ja%'::text))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=1,670
22.          

CTE _preferred_users

23. 0.004 7.426 ↑ 1.0 20 1

Limit (cost=3.36..3.56 rows=20 width=12) (actual time=7.420..7.426 rows=20 loops=1)

  • Buffers: shared hit=9,010
24. 0.015 7.422 ↑ 3.0 20 1

HashAggregate (cost=3.36..3.97 rows=61 width=12) (actual time=7.419..7.422 rows=20 loops=1)

  • Group Key: ((_author.id)::bigint), (0)
  • Buffers: shared hit=9,010
25. 0.005 7.407 ↑ 1.5 41 1

Append (cost=1.64..3.06 rows=61 width=12) (actual time=5.316..7.407 rows=41 loops=1)

  • Buffers: shared hit=9,010
26. 0.018 5.318 ↑ 2.0 21 1

HashAggregate (cost=1.64..2.15 rows=41 width=12) (actual time=5.315..5.318 rows=21 loops=1)

  • Group Key: _author.id, (0)
  • Buffers: shared hit=6,944
27. 0.005 5.300 ↑ 1.0 40 1

Append (cost=0.00..1.44 rows=41 width=8) (actual time=1.607..5.300 rows=40 loops=1)

  • Buffers: shared hit=6,944
28. 0.024 0.024 ↓ 0.0 0 1

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

  • Buffers: shared hit=8
29. 1.631 1.631 ↑ 1.0 20 1

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

  • Buffers: shared hit=3,238
30. 3.640 3.640 ↑ 1.0 20 1

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

  • Buffers: shared hit=3,698
31. 2.084 2.084 ↑ 1.0 20 1

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

  • Buffers: shared hit=2,066
32.          

CTE _other_users

33. 0.004 0.071 ↑ 1.0 20 1

Limit (cost=3.87..6.44 rows=20 width=4) (actual time=0.059..0.071 rows=20 loops=1)

  • Buffers: shared hit=1
34. 0.027 0.067 ↑ 21,388.0 20 1

Seq Scan on users u_5 (cost=3.87..55,067.05 rows=427,761 width=4) (actual time=0.059..0.067 rows=20 loops=1)

  • Filter: ((completed_reg_at IS NOT NULL) AND (id <> 8) AND (NOT (hashed SubPlan 6)) AND (account_status = 'active'::user_account_status))
  • Rows Removed by Filter: 5
  • Buffers: shared hit=1
35.          

SubPlan (for Seq Scan)

36. 0.014 0.040 ↑ 1.5 41 1

HashAggregate (cost=3.11..3.72 rows=61 width=8) (actual time=0.035..0.040 rows=41 loops=1)

  • Group Key: ((_author_1.id)::bigint)
37. 0.003 0.026 ↑ 1.5 41 1

Append (cost=1.54..2.96 rows=61 width=8) (actual time=0.018..0.026 rows=41 loops=1)

38. 0.012 0.021 ↑ 2.0 21 1

HashAggregate (cost=1.54..2.05 rows=41 width=8) (actual time=0.018..0.021 rows=21 loops=1)

  • Group Key: _author_1.id
39. 0.004 0.009 ↑ 1.0 40 1

Append (cost=0.00..1.44 rows=41 width=4) (actual time=0.001..0.009 rows=40 loops=1)

40. 0.000 0.000 ↓ 0.0 0 1

CTE Scan on _author _author_1 (cost=0.00..0.02 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=1)

41. 0.003 0.003 ↑ 1.0 20 1

CTE Scan on _commenters _commenters_1 (cost=0.00..0.40 rows=20 width=4) (actual time=0.000..0.003 rows=20 loops=1)

42. 0.002 0.002 ↑ 1.0 20 1

CTE Scan on _connections _connections_1 (cost=0.00..0.40 rows=20 width=4) (actual time=0.000..0.002 rows=20 loops=1)

43. 0.002 0.002 ↑ 1.0 20 1

CTE Scan on _group_members _group_members_1 (cost=0.00..0.40 rows=20 width=8) (actual time=0.000..0.002 rows=20 loops=1)

44.          

CTE _result

45. 0.003 7.553 ↑ 1.0 20 1

Limit (cost=3.11..3.16 rows=20 width=12) (actual time=7.549..7.553 rows=20 loops=1)

  • Buffers: shared hit=9,011
46. 0.010 7.550 ↑ 2.0 20 1

Sort (cost=3.11..3.21 rows=40 width=12) (actual time=7.549..7.550 rows=20 loops=1)

  • Sort Key: _preferred_users.source_order
  • Sort Method: quicksort Memory: 26kB
  • Buffers: shared hit=9,011
47. 0.024 7.540 ↑ 1.0 40 1

HashAggregate (cost=1.65..2.05 rows=40 width=12) (actual time=7.535..7.540 rows=40 loops=1)

  • Group Key: _preferred_users.id, _preferred_users.source_order
  • Buffers: shared hit=9,011
48. 0.005 7.516 ↑ 1.0 40 1

Append (cost=0.00..1.45 rows=40 width=12) (actual time=7.422..7.516 rows=40 loops=1)

  • Buffers: shared hit=9,011
49. 7.432 7.432 ↑ 1.0 20 1

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

  • Buffers: shared hit=9,010
50. 0.003 0.079 ↑ 1.0 20 1

Subquery Scan on *SELECT* 2 (cost=0.00..0.65 rows=20 width=12) (actual time=0.061..0.079 rows=20 loops=1)

  • Buffers: shared hit=1
51. 0.076 0.076 ↑ 1.0 20 1

CTE Scan on _other_users (cost=0.00..0.40 rows=20 width=8) (actual time=0.061..0.076 rows=20 loops=1)

  • Buffers: shared hit=1
52. 0.039 7.781 ↑ 1.0 20 1

Sort (cost=176.13..176.18 rows=20 width=363) (actual time=7.780..7.781 rows=20 loops=1)

  • Sort Key: _result.source_order, (similarity(concat_ws(' '::text, u.first_name, u.last_name), 'Ja'::text))
  • Sort Method: quicksort Memory: 30kB
  • Buffers: shared hit=9,131
53. 0.069 7.742 ↑ 1.0 20 1

Nested Loop Anti Join (cost=0.72..175.69 rows=20 width=363) (actual time=7.580..7.742 rows=20 loops=1)

  • Buffers: shared hit=9,131
54. 0.015 7.653 ↑ 1.0 20 1

Nested Loop (cost=0.43..169.30 rows=20 width=359) (actual time=7.562..7.653 rows=20 loops=1)

  • Buffers: shared hit=9,091
55. 7.558 7.558 ↑ 1.0 20 1

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

  • Buffers: shared hit=9,011
56. 0.080 0.080 ↑ 1.0 1 20

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

  • Index Cond: (id = _result.id)
  • Buffers: shared hit=80
57. 0.020 0.020 ↓ 0.0 0 20

Index Only Scan using index_user_event_blocks_on_user_id_and_suggested_user_id on user_event_blocks (cost=0.29..0.31 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: ((user_id = 8) AND (suggested_user_id = u.id))
  • Heap Fetches: 0
  • Buffers: shared hit=40
Planning time : 1.536 ms
Execution time : 7.952 ms