explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZLbd

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 135.214 ↑ 3,698.0 2 1

Subquery Scan on feeds_with_reply (cost=66,978.86..67,589.03 rows=7,396 width=458) (actual time=135.207..135.214 rows=2 loops=1)

2. 0.030 135.212 ↑ 3,698.0 2 1

GroupAggregate (cost=66,978.86..67,515.07 rows=7,396 width=466) (actual time=135.206..135.212 rows=2 loops=1)

  • Group Key: f.published, f.logical_id, ((f.content ->> 'relatesto'::text)), ((f.content ->> 'messageDate'::text)), m2.contenttype, ((f.content ->> 'messagetype'::text)), (((f.content -> 'msgdata'::text) ->> 'url'::text)), (((f.content -> 'msgdata'::text) ->> 'message'::text)), p.logical_id, ((p.content ->> 'name'::text)), (((p.content -> 'photo'::text) ->> 'url'::text)), ((array_to_json(array_agg(row_to_json((SubPlan 6)))))::text), ((array_to_json(array_agg(row_to_json((SubPlan 7)))))::text), ((((f.content -> 'episodeOfCare'::text) -> 'identifier'::text) ->> 'value'::text))
3.          

CTE message

4. 0.871 31.872 ↑ 260.6 66 1

GroupAggregate (cost=35,751.31..63,529.31 rows=17,200 width=434) (actual time=30.835..31.872 rows=66 loops=1)

  • Group Key: f_1.logical_id, p_1.logical_id
5. 0.387 30.803 ↑ 260.6 66 1

Sort (cost=35,751.31..35,794.31 rows=17,200 width=2,699) (actual time=30.759..30.803 rows=66 loops=1)

  • Sort Key: f_1.logical_id, p_1.logical_id
  • Sort Method: quicksort Memory: 290kB
6. 5.346 30.416 ↑ 260.6 66 1

Nested Loop Left Join (cost=389.87..14,493.28 rows=17,200 width=2,699) (actual time=1.566..30.416 rows=66 loops=1)

  • Join Filter: (SubPlan 3)
  • Rows Removed by Join Filter: 11352
7. 0.146 0.782 ↑ 3.0 66 1

Hash Join (cost=389.87..431.13 rows=200 width=1,720) (actual time=0.475..0.782 rows=66 loops=1)

  • Hash Cond: ((((f_1.content -> 'messagefrom'::text) -> 'identifier'::text) ->> 'value'::text) = p_1.logical_id)
8. 0.194 0.194 ↑ 3.5 66 1

Seq Scan on feeds f_1 (cost=0.00..37.51 rows=233 width=741) (actual time=0.011..0.194 rows=66 loops=1)

  • Filter: ((content ->> 'relatesto'::text) <> ''::text)
  • Rows Removed by Filter: 163
9. 0.219 0.442 ↓ 1.0 173 1

Hash (cost=387.72..387.72 rows=172 width=979) (actual time=0.442..0.442 rows=173 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 180kB
10. 0.223 0.223 ↓ 1.0 173 1

Seq Scan on person p_1 (cost=0.00..387.72 rows=172 width=979) (actual time=0.003..0.223 rows=173 loops=1)

11. 1.241 1.452 ↓ 1.0 173 66

Materialize (cost=0.00..388.58 rows=172 width=979) (actual time=0.000..0.022 rows=173 loops=66)

12. 0.211 0.211 ↓ 1.0 173 1

Seq Scan on person p2_1 (cost=0.00..387.72 rows=172 width=979) (actual time=0.003..0.211 rows=173 loops=1)

13.          

SubPlan (forNested Loop Left Join)

14. 22.836 22.836 ↑ 100.0 1 11,418

Result (cost=0.00..0.52 rows=100 width=32) (actual time=0.002..0.002 rows=1 loops=11,418)

15.          

SubPlan (forGroupAggregate)

16. 0.000 0.066 ↓ 0.0 0 66

Subquery Scan on d (cost=0.00..1.52 rows=100 width=24) (actual time=0.001..0.001 rows=0 loops=66)

17. 0.066 0.066 ↓ 0.0 0 66

Result (cost=0.00..0.52 rows=100 width=32) (actual time=0.001..0.001 rows=0 loops=66)

18. 0.132 0.132 ↑ 1.0 1 66

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=66)

19. 0.071 135.178 ↑ 3,698.0 2 1

Sort (cost=3,449.55..3,468.04 rows=7,396 width=594) (actual time=135.175..135.178 rows=2 loops=1)

  • Sort Key: f.published DESC, f.logical_id, ((f.content ->> 'relatesto'::text)), ((f.content ->> 'messageDate'::text)), m2.contenttype, ((f.content ->> 'messagetype'::text)), (((f.content -> 'msgdata'::text) ->> 'url'::text)), (((f.content -> 'msgdata'::text) ->> 'message'::text)), p.logical_id, ((p.content ->> 'name'::text)), (((p.content -> 'photo'::text) ->> 'url'::text)), ((array_to_json(array_agg(row_to_json((SubPlan 6)))))::text), ((array_to_json(array_agg(row_to_json((SubPlan 7)))))::text), ((((f.content -> 'episodeOfCare'::text) -> 'identifier'::text) ->> 'value'::text))
  • Sort Method: quicksort Memory: 27kB
20. 0.053 135.107 ↑ 3,698.0 2 1

Hash Right Join (cost=517.80..1,000.26 rows=7,396 width=594) (actual time=135.104..135.107 rows=2 loops=1)

  • Hash Cond: (m2.relatesto = f.logical_id)
21. 31.984 31.984 ↑ 260.6 66 1

CTE Scan on message m2 (cost=0.00..344.00 rows=17,200 width=224) (actual time=30.840..31.984 rows=66 loops=1)

22. 0.009 103.070 ↑ 43.0 2 1

Hash (cost=516.73..516.73 rows=86 width=402) (actual time=103.070..103.070 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
23. 1.850 103.061 ↑ 43.0 2 1

GroupAggregate (cost=504.26..515.87 rows=86 width=402) (actual time=100.569..103.061 rows=2 loops=1)

  • Group Key: f.logical_id, p.logical_id
  • Filter: ((p.logical_id = '3e83622e-db7e-11e8-989f-5934b7dc9afd'::text) OR (((array_to_json(array_agg(row_to_json((SubPlan 9)))))::text ~~ '%3e83622e-db7e-11e8-989f-5934b7dc9afd%'::text) AND ((((f.content -> 'episodeOfCare'::text) -> 'identifier'::text) ->> 'value'::text) = 'e7d3aa3b-f854-11e8-9ad1-55f7711208a4aa'::text)))
  • Rows Removed by Filter: 150
24. 0.944 100.446 ↓ 1.8 153 1

Sort (cost=504.26..504.47 rows=86 width=2,699) (actual time=100.349..100.446 rows=153 loops=1)

  • Sort Key: f.logical_id, p.logical_id
  • Sort Method: quicksort Memory: 635kB
25. 20.252 99.502 ↓ 1.8 153 1

Nested Loop Left Join (cost=0.28..501.49 rows=86 width=2,699) (actual time=0.109..99.502 rows=153 loops=1)

  • Join Filter: (SubPlan 8)
  • Rows Removed by Join Filter: 26145
26. 0.343 1.274 ↓ 152.0 152 1

Nested Loop (cost=0.28..45.83 rows=1 width=1,720) (actual time=0.064..1.274 rows=152 loops=1)

27. 0.279 0.279 ↓ 163.0 163 1

Seq Scan on feeds f (cost=0.00..37.51 rows=1 width=741) (actual time=0.034..0.279 rows=163 loops=1)

  • Filter: ((content ->> 'relatesto'::text) = ''::text)
  • Rows Removed by Filter: 66
28. 0.652 0.652 ↑ 1.0 1 163

Index Scan using person_pkey on person p (cost=0.28..8.31 rows=1 width=979) (actual time=0.004..0.004 rows=1 loops=163)

  • Index Cond: (logical_id = (((f.content -> 'messagefrom'::text) -> 'identifier'::text) ->> 'value'::text))
29. 25.384 25.384 ↓ 1.0 173 152

Seq Scan on person p2 (cost=0.00..387.72 rows=172 width=979) (actual time=0.001..0.167 rows=173 loops=152)

30.          

SubPlan (forNested Loop Left Join)

31. 52.592 52.592 ↑ 100.0 1 26,296

Result (cost=0.00..0.52 rows=100 width=32) (actual time=0.002..0.002 rows=1 loops=26,296)

32.          

SubPlan (forGroupAggregate)

33. 0.306 0.306 ↑ 1.0 1 153

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=153)

34. 0.153 0.153 ↑ 1.0 1 153

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=153)

35. 0.306 0.306 ↑ 1.0 1 153

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=153)

36.          

SubPlan (forGroupAggregate)

37. 0.004 0.004 ↑ 1.0 1 2

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=2)