explain.depesz.com

A tool for finding a real cause for slow queries.

Result: WK8

options
Did it help? Consider supporting us - Bitcoin address: 12v2hUztAk2LgzQ9H9LMwuU32urHMjZQnq
# exclusive inclusive rows x rows loops node
1. 0.005 5606527.528 ↓ 15.0 30 1

Limit (cost=532358.63..532358.64 rows=2 width=352) (actual time=5606527.522..5606527.528 rows=30 loops=1)

2. 52.241 5606527.523 ↓ 15.0 30 1

Sort (cost=532358.63..532358.64 rows=2 width=352) (actual time=5606527.521..5606527.523 rows=30 loops=1)

  • Sort Key: br.created_at
  • Sort Method: top-N heapsort Memory: 40kB
3. 44.607 5606475.282 ↓ 5339.5 10679 1

Nested Loop Left Join (cost=450077.88..532358.62 rows=2 width=352) (actual time=118745.919..5606475.282 rows=10679 loops=1)

4. 11.487 5606409.317 ↓ 5339.5 10679 1

Nested Loop Left Join (cost=450077.88..532358.03 rows=2 width=349) (actual time=118745.883..5606409.317 rows=10679 loops=1)

5. 17.420 5606226.966 ↓ 5339.5 10679 1

Nested Loop Left Join (cost=450077.88..532357.24 rows=2 width=343) (actual time=118743.758..5606226.966 rows=10679 loops=1)

  • Join Filter: ((max(cl.created_at)) = cl.created_at)
6. 12.355 5606102.756 ↓ 5339.5 10679 1

Hash Left Join (cost=450077.88..532340.66 rows=2 width=339) (actual time=118743.721..5606102.756 rows=10679 loops=1)

  • Hash Cond: (c.customer_id = cl.customer_id)
7. 34.751 5605801.719 ↓ 5339.5 10679 1

Hash Left Join (cost=433226.67..515489.04 rows=2 width=331) (actual time=118455.009..5605801.719 rows=10679 loops=1)

  • Hash Cond: (sel.selection_id = s.selection_id)
8. 18.316 5600635.369 ↓ 5339.5 10679 1

Nested Loop Left Join (cost=186331.59..268504.20 rows=2 width=327) (actual time=113323.196..5600635.369 rows=10679 loops=1)

9. 44.649 5599997.671 ↓ 5339.5 10679 1

Hash Left Join (cost=186331.59..268487.51 rows=2 width=328) (actual time=113323.189..5599997.671 rows=10679 loops=1)

  • Hash Cond: (e.event_id = kw_league.event_id)
10. 44.239 5599821.303 ↓ 5339.5 10679 1

Hash Left Join (cost=179542.11..261693.25 rows=2 width=304) (actual time=113191.443..5599821.303 rows=10679 loops=1)

  • Hash Cond: (e.event_id = kw_sport.event_id)
11. 18.577 5599616.807 ↓ 5339.5 10679 1

Nested Loop (cost=172752.63..254899.00 rows=2 width=280) (actual time=113031.157..5599616.807 rows=10679 loops=1)

12. 19.569 5599555.514 ↓ 5339.5 10679 1

Nested Loop (cost=172752.63..254898.40 rows=2 width=245) (actual time=113031.143..5599555.514 rows=10679 loops=1)

13. 11.671 5599268.970 ↓ 5339.5 10679 1

Hash Left Join (cost=172752.63..254897.63 rows=2 width=219) (actual time=113030.882..5599268.970 rows=10679 loops=1)

  • Hash Cond: (br.bet_client_id = bc.bet_client_id)
14. 10.687 5599257.288 ↓ 5339.5 10679 1

Nested Loop (cost=172751.54..254896.51 rows=2 width=206) (actual time=113030.844..5599257.288 rows=10679 loops=1)

15. 172.532 5597666.109 ↓ 5339.5 10679 1

Hash Join (cost=172751.54..254879.35 rows=2 width=194) (actual time=113029.723..5597666.109 rows=10679 loops=1)

  • Hash Cond: (p.placement_id = s.placement_id)
16. 11.086 5489531.357 ↓ 5339.5 10679 1

Nested Loop (cost=140821.67..222949.46 rows=2 width=218) (actual time=5067.472..5489531.357 rows=10679 loops=1)

17. 40.484 5489482.241 ↓ 3803.0 3803 1

Hash Join (cost=140821.67..222940.84 rows=1 width=185) (actual time=5067.204..5489482.241 rows=3803 loops=1)

  • Hash Cond: (er.target_id = erc.currency_id)
18. 92.676 5489441.734 ↓ 6596.5 197895 1

Nested Loop (cost=140819.96..222939.00 rows=30 width=187) (actual time=5057.894..5489441.734 rows=197895 loops=1)

19. 194688.833 5488748.184 ↓ 3803.0 3803 1

Nested Loop Left Join (cost=140819.95..222937.22 rows=1 width=179) (actual time=5056.118..5488748.184 rows=3803 loops=1)

  • Join Filter: (s.placement_id = p.placement_id)
20. 43.133 5622.763 ↓ 3803.0 3803 1

Hash Join (cost=86285.75..150307.67 rows=1 width=155) (actual time=2856.974..5622.763 rows=3803 loops=1)

  • Hash Cond: (p.placement_id = s.placement_id)
21. 583.566 4929.951 ↓ 952.5 26669 1

Hash Join (cost=54355.88..118377.68 rows=28 width=147) (actual time=2099.862..4929.951 rows=26669 loops=1)

  • Hash Cond: (p.placement_id = s.placement_id)
22. 468.566 3216.271 ↑ 1.0 608689 1

Hash Join (cost=22426.01..84162.44 rows=609358 width=139) (actual time=968.294..3216.271 rows=608689 loops=1)

  • Hash Cond: (br.customer_id = c.customer_id)
23. 796.007 2658.304 ↑ 1.0 608689 1

Hash Join (cost=20071.37..67335.55 rows=609358 width=105) (actual time=878.864..2658.304 rows=608689 loops=1)

  • Hash Cond: (p.bet_request_id = br.bet_request_id)
24. 183.783 983.723 ↑ 1.0 608689 1

Hash Join (cost=3.85..32795.77 rows=609358 width=63) (actual time=0.080..983.723 rows=608689 loops=1)

  • Hash Cond: (p.currency_id = cu.currency_id)
25. 223.633 799.916 ↑ 1.0 608689 1

Hash Join (cost=1.58..24414.84 rows=609358 width=57) (actual time=0.034..799.916 rows=608689 loops=1)

  • Hash Cond: (p.bet_type_id = bt.bet_type_id)
26. 576.270 576.270 ↑ 1.0 608689 1

Seq Scan on placements p (cost=0.00..16034.58 rows=609358 width=46) (actual time=0.009..576.270 rows=608689 loops=1)

27. 0.007 0.013 ↑ 1.0 26 1

Hash (cost=1.26..1.26 rows=26 width=13) (actual time=0.013..0.013 rows=26 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
28. 0.006 0.006 ↑ 1.0 26 1

Seq Scan on bet_types bt (cost=0.00..1.26 rows=26 width=13) (actual time=0.002..0.006 rows=26 loops=1)

29. 0.014 0.024 ↑ 1.0 56 1

Hash (cost=1.56..1.56 rows=56 width=6) (actual time=0.024..0.024 rows=56 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 3kB
30. 0.010 0.010 ↑ 1.0 56 1

Seq Scan on currencies cu (cost=0.00..1.56 rows=56 width=6) (actual time=0.003..0.010 rows=56 loops=1)

31. 162.662 878.574 ↑ 1.0 575856 1

Hash (cost=12868.90..12868.90 rows=575890 width=50) (actual time=878.574..878.574 rows=575856 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 44282kB
32. 715.912 715.912 ↑ 1.0 575856 1

Seq Scan on bet_requests br (cost=0.00..12868.90 rows=575890 width=50) (actual time=0.345..715.912 rows=575856 loops=1)

33. 13.587 89.401 ↑ 1.0 36523 1

Hash (cost=1897.46..1897.46 rows=36574 width=50) (actual time=89.401..89.401 rows=36523 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 2997kB
34. 10.950 75.814 ↑ 1.0 36523 1

Hash Join (cost=4.64..1897.46 rows=36574 width=50) (actual time=0.348..75.814 rows=36523 loops=1)

  • Hash Cond: (c.country_id = country.country_id)
35. 9.471 64.799 ↑ 1.0 36523 1

Nested Loop (cost=0.00..1389.92 rows=36574 width=47) (actual time=0.270..64.799 rows=36523 loops=1)

  • Join Filter: (op.operator_id = c.operator_id)
36. 0.258 0.258 ↑ 1.0 1 1

Seq Scan on operators op (cost=0.00..1.01 rows=1 width=13) (actual time=0.257..0.258 rows=1 loops=1)

37. 55.070 55.070 ↑ 1.0 36523 1

Seq Scan on customers c (cost=0.00..931.74 rows=36574 width=36) (actual time=0.004..55.070 rows=36523 loops=1)

38. 0.038 0.065 ↓ 1.1 174 1

Hash (cost=2.62..2.62 rows=162 width=5) (actual time=0.065..0.065 rows=174 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 7kB
39. 0.027 0.027 ↓ 1.1 174 1

Seq Scan on countries country (cost=0.00..2.62 rows=162 width=5) (actual time=0.007..0.027 rows=174 loops=1)

40. 4.606 1130.114 ↓ 952.5 26669 1

Hash (cost=31929.52..31929.52 rows=28 width=8) (actual time=1130.114..1130.114 rows=26669 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1042kB
41. 19.788 1125.508 ↓ 952.5 26669 1

HashAggregate (cost=31928.96..31929.24 rows=28 width=8) (actual time=1120.181..1125.508 rows=26669 loops=1)

42. 856.476 1105.720 ↓ 1298.1 36348 1

Hash Join (cost=5571.61..31928.89 rows=28 width=8) (actual time=142.697..1105.720 rows=36348 loops=1)

  • Hash Cond: (s.outcome_id = o.outcome_id)
43. 106.567 106.567 ↓ 1.0 1141228 1

Seq Scan on selections s (cost=0.00..22077.64 rows=1141164 width=12) (actual time=0.002..106.567 rows=1141228 loops=1)

44. 9.128 142.677 ↓ 648.4 38903 1

Hash (cost=5570.86..5570.86 rows=60 width=4) (actual time=142.677..142.677 rows=38903 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1368kB
45. 15.280 133.549 ↓ 648.4 38903 1

Nested Loop (cost=8.28..5570.86 rows=60 width=4) (actual time=0.403..133.549 rows=38903 loops=1)

46. 2.199 65.489 ↓ 776.2 13195 1

Nested Loop (cost=8.28..5551.77 rows=17 width=4) (actual time=0.393..65.489 rows=13195 loops=1)

47. 0.428 56.764 ↓ 251.0 502 1

Nested Loop (cost=8.28..5549.43 rows=2 width=8) (actual time=0.384..56.764 rows=502 loops=1)

48. 0.150 55.332 ↓ 251.0 502 1

Nested Loop (cost=8.28..5548.81 rows=2 width=4) (actual time=0.368..55.332 rows=502 loops=1)

  • Join Filter: (k.keyword_type_id = kt.keyword_type_id)
49. 0.007 0.007 ↑ 1.0 1 1

Seq Scan on keyword_types kt (cost=0.00..1.20 rows=1 width=4) (actual time=0.004..0.007 rows=1 loops=1)

  • Filter: (cname = 'country'::text)
50. 30.507 55.175 ↓ 20.1 502 1

Hash Join (cost=8.28..5547.30 rows=25 width=8) (actual time=0.357..55.175 rows=502 loops=1)

  • Hash Cond: (ek.keyword_id = k.keyword_id)
51. 24.408 24.408 ↓ 1.0 304794 1

Seq Scan on events_keywords ek (cost=0.00..4396.10 rows=304710 width=8) (actual time=0.002..24.408 rows=304794 loops=1)

52. 0.002 0.260 ↑ 1.0 1 1

Hash (cost=8.27..8.27 rows=1 width=12) (actual time=0.260..0.260 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
53. 0.258 0.258 ↑ 1.0 1 1

Index Scan using keywords_cname_keyword_type_id_idx on keywords k (cost=0.00..8.27 rows=1 width=12) (actual time=0.256..0.258 rows=1 loops=1)

  • Index Cond: (cname = 'european-cups'::text)
54. 1.004 1.004 ↑ 1.0 1 502

Index Scan using events_pkey on events e (cost=0.00..0.30 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=502)

  • Index Cond: (event_id = ek.event_id)
55. 6.526 6.526 ↓ 1.2 26 502

Index Scan using markets_event_id_idx on markets m (cost=0.00..0.91 rows=21 width=8) (actual time=0.004..0.013 rows=26 loops=502)

  • Index Cond: (event_id = e.event_id)
56. 52.780 52.780 ↑ 4.0 3 13195

Index Scan using outcomes_market_id_idx on outcomes o (cost=0.00..0.97 rows=12 width=8) (actual time=0.004..0.004 rows=3 loops=13195)

  • Index Cond: (market_id = m.market_id)
57. 2.534 649.679 ↓ 516.1 14451 1

Hash (cost=31929.52..31929.52 rows=28 width=8) (actual time=649.679..649.679 rows=14451 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 565kB
58. 11.396 647.145 ↓ 516.1 14451 1

HashAggregate (cost=31928.96..31929.24 rows=28 width=8) (actual time=644.366..647.145 rows=14451 loops=1)

59. 451.319 635.749 ↓ 1081.2 30273 1

Hash Join (cost=5571.61..31928.89 rows=28 width=8) (actual time=102.718..635.749 rows=30273 loops=1)

  • Hash Cond: (s.outcome_id = o.outcome_id)
60. 97.860 97.860 ↓ 1.0 1141228 1

Seq Scan on selections s (cost=0.00..22077.64 rows=1141164 width=12) (actual time=0.003..97.860 rows=1141228 loops=1)

61. 5.130 86.570 ↓ 366.1 21964 1

Hash (cost=5570.86..5570.86 rows=60 width=4) (actual time=86.570..86.570 rows=21964 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 773kB
62. 4.480 81.440 ↓ 366.1 21964 1

Nested Loop (cost=8.28..5570.86 rows=60 width=4) (actual time=0.896..81.440 rows=21964 loops=1)

63. 0.992 60.259 ↓ 327.5 5567 1

Nested Loop (cost=8.28..5551.77 rows=17 width=4) (actual time=0.888..60.259 rows=5567 loops=1)

64. 0.141 56.930 ↓ 61.5 123 1

Nested Loop (cost=8.28..5549.43 rows=2 width=8) (actual time=0.879..56.930 rows=123 loops=1)

65. 0.038 56.543 ↓ 61.5 123 1

Nested Loop (cost=8.28..5548.81 rows=2 width=4) (actual time=0.868..56.543 rows=123 loops=1)

  • Join Filter: (k.keyword_type_id = kt.keyword_type_id)
66. 0.007 0.007 ↑ 1.0 1 1

Seq Scan on keyword_types kt (cost=0.00..1.20 rows=1 width=4) (actual time=0.004..0.007 rows=1 loops=1)

  • Filter: (cname = 'league'::text)
67. 31.278 56.498 ↓ 4.9 123 1

Hash Join (cost=8.28..5547.30 rows=25 width=8) (actual time=0.857..56.498 rows=123 loops=1)

  • Hash Cond: (ek.keyword_id = k.keyword_id)
68. 24.945 24.945 ↓ 1.0 304794 1

Seq Scan on events_keywords ek (cost=0.00..4396.10 rows=304710 width=8) (actual time=0.003..24.945 rows=304794 loops=1)

69. 0.002 0.275 ↑ 1.0 1 1

Hash (cost=8.27..8.27 rows=1 width=12) (actual time=0.275..0.275 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
70. 0.273 0.273 ↑ 1.0 1 1

Index Scan using keywords_cname_keyword_type_id_idx on keywords k (cost=0.00..8.27 rows=1 width=12) (actual time=0.272..0.273 rows=1 loops=1)

  • Index Cond: (cname = 'uefa-europa-league'::text)
71. 0.246 0.246 ↑ 1.0 1 123

Index Scan using events_pkey on events e (cost=0.00..0.30 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=123)

  • Index Cond: (event_id = ek.event_id)
72. 2.337 2.337 ↓ 2.1 45 123

Index Scan using markets_event_id_idx on markets m (cost=0.00..0.91 rows=21 width=8) (actual time=0.004..0.019 rows=45 loops=123)

  • Index Cond: (event_id = e.event_id)
73. 16.701 16.701 ↑ 3.0 4 5567

Index Scan using outcomes_market_id_idx on outcomes o (cost=0.00..0.97 rows=12 width=8) (actual time=0.002..0.003 rows=4 loops=5567)

  • Index Cond: (market_id = m.market_id)
74. 4514573.804 5288436.588 ↓ 3.4 606788 3803

Hash Join (cost=54534.20..70395.56 rows=178719 width=32) (actual time=0.509..1390.596 rows=606788 loops=3803)

  • Hash Cond: ((max(settlements.settlement_id)) = s.settlement_id)
75. 772261.801 773347.656 ↓ 1.1 606821 3803

HashAggregate (cost=25288.38..30649.97 rows=536159 width=16) (actual time=0.371..203.352 rows=606821 loops=3803)

76. 1085.855 1085.855 ↑ 1.0 632966 1

Seq Scan on settlements (cost=0.00..22123.25 rows=633025 width=16) (actual time=0.010..1085.855 rows=632966 loops=1)

77. 163.704 515.128 ↓ 2.9 619887 1

Hash (cost=26608.22..26608.22 rows=211008 width=40) (actual time=515.128..515.128 rows=619887 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 42335kB
78. 270.810 351.424 ↓ 2.9 619887 1

Hash Join (cost=1.05..26608.22 rows=211008 width=40) (actual time=0.025..351.424 rows=619887 loops=1)

  • Hash Cond: (s.operation_id = so.id)
79. 80.604 80.604 ↑ 1.0 632966 1

Seq Scan on settlements s (cost=0.00..22123.25 rows=633025 width=42) (actual time=0.002..80.604 rows=632966 loops=1)

80. 0.003 0.010 ↑ 1.0 1 1

Hash (cost=1.04..1.04 rows=1 width=2) (actual time=0.010..0.010 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
81. 0.007 0.007 ↑ 1.0 1 1

Seq Scan on settlement_operations so (cost=0.00..1.04 rows=1 width=2) (actual time=0.006..0.007 rows=1 loops=1)

  • Filter: (cname = 'settle'::text)
82. 600.874 600.874 ↓ 1.7 52 3803

Index Scan using exchange_rates_date_source_id_target_id_idx on exchange_rates er (cost=0.01..1.04 rows=30 width=16) (actual time=0.090..0.158 rows=52 loops=3803)

  • Index Cond: ((date = COALESCE((timezone('UTC'::text, s.created_at))::date, (timezone('UTC'::text, br.created_at))::date)) AND (source_id = cu.currency_id))
83. 0.002 0.023 ↑ 1.0 1 1

Hash (cost=1.70..1.70 rows=1 width=2) (actual time=0.023..0.023 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
84. 0.021 0.021 ↑ 1.0 1 1

Seq Scan on currencies erc (cost=0.00..1.70 rows=1 width=2) (actual time=0.021..0.021 rows=1 loops=1)

  • Filter: (code = 'EUR'::bpchar)
85. 38.030 38.030 ↑ 1.3 3 3803

Index Scan using selections_placement_id_idx on selections sel (cost=0.00..8.58 rows=4 width=33) (actual time=0.009..0.010 rows=3 loops=3803)

  • Index Cond: (placement_id = p.placement_id)
86. 63.145 107962.220 ↓ 13130.4 367650 1

Hash (cost=31929.52..31929.52 rows=28 width=8) (actual time=107962.220..107962.220 rows=367650 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 14362kB
87. 555.419 107899.075 ↓ 13130.4 367650 1

HashAggregate (cost=31928.96..31929.24 rows=28 width=8) (actual time=107790.951..107899.075 rows=367650 loops=1)

88. 98724.977 107343.656 ↓ 24515.6 686438 1

Hash Join (cost=5571.61..31928.89 rows=28 width=8) (actual time=8045.980..107343.656 rows=686438 loops=1)

  • Hash Cond: (s.outcome_id = o.outcome_id)
89. 572.876 572.876 ↓ 1.0 1141228 1

Seq Scan on selections s (cost=0.00..22077.64 rows=1141164 width=12) (actual time=0.022..572.876 rows=1141228 loops=1)

90. 331.911 8045.803 ↓ 25245.7 1514741 1

Hash (cost=5570.86..5570.86 rows=60 width=4) (actual time=8045.803..8045.803 rows=1514741 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 53253kB
91. 393.452 7713.892 ↓ 25245.7 1514741 1

Nested Loop (cost=8.28..5570.86 rows=60 width=4) (actual time=20.002..7713.892 rows=1514741 loops=1)

92. 70.107 1541.928 ↓ 21244.5 361157 1

Nested Loop (cost=8.28..5551.77 rows=17 width=4) (actual time=12.761..1541.928 rows=361157 loops=1)

93. 2.165 237.389 ↓ 9644.0 19288 1

Nested Loop (cost=8.28..5549.43 rows=2 width=8) (actual time=12.113..237.389 rows=19288 loops=1)

94. 5.083 119.496 ↓ 9644.0 19288 1

Nested Loop (cost=8.28..5548.81 rows=2 width=4) (actual time=11.834..119.496 rows=19288 loops=1)

  • Join Filter: (k.keyword_type_id = kt.keyword_type_id)
95. 0.009 0.009 ↑ 1.0 1 1

Seq Scan on keyword_types kt (cost=0.00..1.20 rows=1 width=4) (actual time=0.006..0.009 rows=1 loops=1)

  • Filter: (cname = 'sport'::text)
96. 43.889 114.404 ↓ 780.7 19517 1

Hash Join (cost=8.28..5547.30 rows=25 width=8) (actual time=11.824..114.404 rows=19517 loops=1)

  • Hash Cond: (ek.keyword_id = k.keyword_id)
97. 59.041 59.041 ↓ 1.0 304794 1

Seq Scan on events_keywords ek (cost=0.00..4396.10 rows=304710 width=8) (actual time=0.320..59.041 rows=304794 loops=1)

98. 0.006 11.474 ↓ 2.0 2 1

Hash (cost=8.27..8.27 rows=1 width=12) (actual time=11.474..11.474 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
99. 11.468 11.468 ↓ 2.0 2 1

Index Scan using keywords_cname_keyword_type_id_idx on keywords k (cost=0.00..8.27 rows=1 width=12) (actual time=0.924..11.468 rows=2 loops=1)

  • Index Cond: (cname = 'soccer'::text)
100. 115.728 115.728 ↑ 1.0 1 19288

Index Scan using events_pkey on events e (cost=0.00..0.30 rows=1 width=4) (actual time=0.005..0.006 rows=1 loops=19288)

  • Index Cond: (event_id = ek.event_id)
101. 1234.432 1234.432 ↑ 1.1 19 19288

Index Scan using markets_event_id_idx on markets m (cost=0.00..0.91 rows=21 width=8) (actual time=0.026..0.064 rows=19 loops=19288)

  • Index Cond: (event_id = e.event_id)
102. 5778.512 5778.512 ↑ 3.0 4 361157

Index Scan using outcomes_market_id_idx on outcomes o (cost=0.00..0.97 rows=12 width=8) (actual time=0.012..0.016 rows=4 loops=361157)

  • Index Cond: (market_id = m.market_id)
103. 1580.492 1580.492 ↑ 1.0 1 10679

Index Scan using outcomes_pkey on outcomes o (cost=0.00..8.57 rows=1 width=16) (actual time=0.147..0.148 rows=1 loops=10679)

  • Index Cond: (outcome_id = sel.outcome_id)
104. 0.006 0.011 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=15) (actual time=0.011..0.011 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
105. 0.005 0.005 ↑ 1.0 4 1

Seq Scan on bet_clients bc (cost=0.00..1.04 rows=4 width=15) (actual time=0.004..0.005 rows=4 loops=1)

106. 266.975 266.975 ↑ 1.0 1 10679

Index Scan using markets_pkey on markets m (cost=0.00..0.37 rows=1 width=30) (actual time=0.025..0.025 rows=1 loops=10679)

  • Index Cond: (market_id = o.market_id)
107. 42.716 42.716 ↑ 1.0 1 10679

Index Scan using events_pkey on events e (cost=0.00..0.28 rows=1 width=39) (actual time=0.004..0.004 rows=1 loops=10679)

  • Index Cond: (event_id = m.event_id)
108. 12.233 160.257 ↓ 2.8 52952 1

Hash (cost=6551.43..6551.43 rows=19044 width=28) (actual time=160.257..160.257 rows=52952 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 3089kB
109. 7.365 148.024 ↓ 2.8 52952 1

Subquery Scan on kw_sport (cost=6170.55..6551.43 rows=19044 width=28) (actual time=128.062..148.024 rows=52952 loops=1)

110. 33.269 140.659 ↓ 2.8 52952 1

HashAggregate (cost=6170.55..6360.99 rows=19044 width=28) (actual time=128.060..140.659 rows=52952 loops=1)

111. 41.401 107.390 ↓ 2.8 52952 1

Hash Join (cost=298.53..6027.72 rows=19044 width=28) (actual time=40.402..107.390 rows=52952 loops=1)

  • Hash Cond: (ek.keyword_id = k.keyword_id)
112. 25.609 25.609 ↓ 1.0 304794 1

Seq Scan on events_keywords ek (cost=0.00..4396.10 rows=304710 width=8) (actual time=0.005..25.609 rows=304794 loops=1)

113. 0.022 40.380 ↑ 12.3 62 1

Hash (cost=289.03..289.03 rows=760 width=24) (actual time=40.380..40.380 rows=62 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 3kB
114. 1.549 40.358 ↑ 12.3 62 1

Hash Join (cost=1.21..289.03 rows=760 width=24) (actual time=0.034..40.358 rows=62 loops=1)

  • Hash Cond: (k.keyword_type_id = kt.keyword_type_id)
115. 38.798 38.798 ↑ 1.0 12126 1

Seq Scan on keywords k (cost=0.00..234.61 rows=12161 width=28) (actual time=0.008..38.798 rows=12126 loops=1)

116. 0.003 0.011 ↑ 1.0 1 1

Hash (cost=1.20..1.20 rows=1 width=4) (actual time=0.011..0.011 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
117. 0.008 0.008 ↑ 1.0 1 1

Seq Scan on keyword_types kt (cost=0.00..1.20 rows=1 width=4) (actual time=0.006..0.008 rows=1 loops=1)

  • Filter: (cname = 'sport'::text)
118. 13.977 131.719 ↓ 2.8 52820 1

Hash (cost=6551.43..6551.43 rows=19044 width=28) (actual time=131.719..131.719 rows=52820 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 3246kB
119. 7.378 117.742 ↓ 2.8 52820 1

Subquery Scan on kw_league (cost=6170.55..6551.43 rows=19044 width=28) (actual time=97.005..117.742 rows=52820 loops=1)

120. 35.214 110.364 ↓ 2.8 52820 1

HashAggregate (cost=6170.55..6360.99 rows=19044 width=28) (actual time=97.004..110.364 rows=52820 loops=1)

121. 46.393 75.150 ↓ 2.8 52820 1

Hash Join (cost=298.53..6027.72 rows=19044 width=28) (actual time=3.085..75.150 rows=52820 loops=1)

  • Hash Cond: (ek.keyword_id = k.keyword_id)
122. 25.695 25.695 ↓ 1.0 304794 1

Seq Scan on events_keywords ek (cost=0.00..4396.10 rows=304710 width=8) (actual time=0.007..25.695 rows=304794 loops=1)

123. 0.255 3.062 ↓ 1.4 1067 1

Hash (cost=289.03..289.03 rows=760 width=24) (actual time=3.062..3.062 rows=1067 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 62kB
124. 1.666 2.807 ↓ 1.4 1067 1

Hash Join (cost=1.21..289.03 rows=760 width=24) (actual time=0.022..2.807 rows=1067 loops=1)

  • Hash Cond: (k.keyword_type_id = kt.keyword_type_id)
125. 1.134 1.134 ↑ 1.0 12126 1

Seq Scan on keywords k (cost=0.00..234.61 rows=12161 width=28) (actual time=0.006..1.134 rows=12126 loops=1)

126. 0.001 0.007 ↑ 1.0 1 1

Hash (cost=1.20..1.20 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
127. 0.006 0.006 ↑ 1.0 1 1

Seq Scan on keyword_types kt (cost=0.00..1.20 rows=1 width=4) (actual time=0.004..0.006 rows=1 loops=1)

  • Filter: (cname = 'league'::text)
128. 619.382 619.382 ↑ 1.0 1 10679

Index Scan using sessions_pkey on sessions ses (cost=0.00..8.33 rows=1 width=15) (actual time=0.058..0.058 rows=1 loops=10679)

  • Index Cond: (session_id = br.session_tracker_id)
129. 362.988 5131.599 ↓ 3.2 1137794 1

Hash (cost=242407.69..242407.69 rows=358991 width=12) (actual time=5131.599..5131.599 rows=1137794 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 48890kB
130. 1111.423 4768.611 ↓ 3.2 1137794 1

HashAggregate (cost=235227.87..238817.78 rows=358991 width=12) (actual time=4411.522..4768.611 rows=1137794 loops=1)

131. 343.014 3657.188 ↓ 3.2 1147084 1

Hash Left Join (cost=180611.03..233432.91 rows=358991 width=12) (actual time=1645.513..3657.188 rows=1147084 loops=1)

  • Hash Cond: ((s.placement_id = s.placement_id) AND (s.selection_id = s.selection_id))
  • Filter: (((s.placement_id IS NULL) AND (r.placement_id IS NULL)) OR ((s.placement_id IS NOT NULL) AND (r.placement_id IS NULL) AND (r.created_at < (min(r.created_at)))) OR (s.placement_id = r.placement_id))
132. 489.099 2583.544 ↓ 1.1 1163068 1

Merge Join (cost=136896.54..181640.03 rows=1077117 width=36) (actual time=914.861..2583.544 rows=1163068 loops=1)

  • Merge Cond: (r.outcome_id = s.outcome_id)
  • Join Filter: (s.handicap = r.handicap)
133. 986.556 986.556 ↓ 1.0 341537 1

Index Scan using results_outcome_id_idx on results r (cost=0.00..19930.18 rows=341499 width=28) (actual time=0.017..986.556 rows=341537 loops=1)

134. 948.828 1107.889 ↓ 1.1 1282406 1

Sort (cost=136890.58..139743.49 rows=1141164 width=24) (actual time=914.828..1107.889 rows=1282406 loops=1)

  • Sort Key: s.outcome_id
  • Sort Method: quicksort Memory: 138311kB
135. 159.061 159.061 ↓ 1.0 1141228 1

Seq Scan on selections s (cost=0.00..22077.64 rows=1141164 width=24) (actual time=0.005..159.061 rows=1141228 loops=1)

136. 0.330 730.630 ↓ 1300.0 1300 1

Hash (cost=43714.48..43714.48 rows=1 width=24) (actual time=730.630..730.630 rows=1300 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 72kB
137. 1.707 730.300 ↓ 1300.0 1300 1

HashAggregate (cost=43714.46..43714.47 rows=1 width=24) (actual time=730.004..730.300 rows=1300 loops=1)

138. 112.690 728.593 ↓ 1736.0 1736 1

Merge Join (cost=250.22..43714.45 rows=1 width=24) (actual time=14.308..728.593 rows=1736 loops=1)

  • Merge Cond: (s.placement_id = r.placement_id)
  • Join Filter: ((s.outcome_id = r.outcome_id) AND (s.handicap = r.handicap))
139. 357.902 357.902 ↑ 1.0 1138900 1

Index Scan using selections_placement_id_idx on selections s (cost=0.00..40660.89 rows=1141164 width=24) (actual time=0.018..357.902 rows=1138900 loops=1)

140. 258.001 258.001 ↑ 96.1 3553 1

Index Scan using results_placement_id_idx on results r (cost=0.00..17740.90 rows=341499 width=24) (actual time=0.571..258.001 rows=3553 loops=1)

141. 0.245 288.682 ↑ 1.4 1101 1

Hash (cost=16831.43..16831.43 rows=1583 width=24) (actual time=288.682..288.682 rows=1101 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 61kB
142. 21.957 288.437 ↑ 1.4 1101 1

HashAggregate (cost=16799.77..16815.60 rows=1583 width=24) (actual time=288.269..288.437 rows=1101 loops=1)

143. 106.609 266.480 ↓ 6.5 81391 1

Hash Join (cost=519.66..16737.21 rows=12512 width=24) (actual time=109.463..266.480 rows=81391 loops=1)

  • Hash Cond: (br.customer_id = cl.customer_id)
  • Join Filter: (br.created_at >= cl.created_at)
144. 50.456 50.456 ↑ 1.0 575856 1

Seq Scan on bet_requests br (cost=0.00..12868.90 rows=575890 width=24) (actual time=0.008..50.456 rows=575856 loops=1)

145. 0.485 109.415 ↓ 1.0 1610 1

Hash (cost=499.87..499.87 rows=1583 width=24) (actual time=109.415..109.415 rows=1610 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 89kB
146. 108.930 108.930 ↓ 1.0 1610 1

Seq Scan on customer_limits cl (cost=0.00..499.87 rows=1583 width=24) (actual time=21.553..108.930 rows=1610 loops=1)

  • Filter: (max_bet IS NOT NULL)
147. 106.790 106.790 ↑ 1.0 1 10679

Index Scan using customer_limits_customer_id_idx on customer_limits cl (cost=0.00..8.27 rows=1 width=36) (actual time=0.010..0.010 rows=1 loops=10679)

  • Index Cond: (customer_id = c.customer_id)
148. 170.864 170.864 ↑ 1.0 1 10679

Index Scan using results_pkey on results (cost=0.00..0.38 rows=1 width=14) (actual time=0.016..0.016 rows=1 loops=10679)

  • Index Cond: (result_id = (max(r.result_id)))
149. 21.358 21.358 ↑ 1.0 1 10679

Index Scan using result_types_pkey on result_types (cost=0.00..0.27 rows=1 width=7) (actual time=0.002..0.002 rows=1 loops=10679)

  • Index Cond: (result_type_id = results.result_type_id)