explain.depesz.com

PostgreSQL's explain analyze made readable

Result: k8xc

Settings
# exclusive inclusive rows x rows loops node
1. 0.012 5,983.157 ↑ 1.0 1 1

Result (cost=389,641.82..389,641.83 rows=1 width=64) (actual time=5,983.156..5,983.157 rows=1 loops=1)

2.          

CTE allRows

3. 5,963.568 5,963.568 ↑ 5.5 5,853 1

CTE Scan on ""baseRows"" (cost=385,115.91..386,321.76 rows=32,156 width=1,010) (actual time=3,017.661..5,963.568 rows=5,853 loops=1)

4.          

CTE baseRows

5. 170.538 5,942.205 ↑ 5.5 5,853 1

GroupAggregate (cost=295,400.49..385,115.91 rows=32,156 width=179) (actual time=3,017.655..5,942.205 rows=5,853 loops=1)

  • Group Key: s.user_id, urs.country_code, ""user"".first_name, ""user"".last_name
6. 163.897 3,032.463 ↓ 1.5 47,792 1

Sort (cost=295,400.49..295,480.88 rows=32,156 width=145) (actual time=3,017.323..3,032.463 rows=47,792 loops=1)

  • Sort Key: s.user_id, urs.country_code, ""user"".first_name, ""user"".last_name
  • Sort Method: quicksort Memory: 14231kB
7. 142.897 2,868.566 ↓ 1.5 47,792 1

Hash Left Join (cost=37,866.92..292,993.16 rows=32,156 width=145) (actual time=810.654..2,868.566 rows=47,792 loops=1)

  • Hash Cond: ((urs.risk_group_id = crs.risk_group_id) AND (((SubPlan 2))::text = (crs.country_code)::text))
8. 58.433 2,725.548 ↓ 1.5 47,792 1

Hash Left Join (cost=37,861.00..289,737.07 rows=32,156 width=144) (actual time=810.486..2,725.548 rows=47,792 loops=1)

  • Hash Cond: ((s.bet_id)::text = (co.bet_id)::text)
9. 35.186 2,452.734 ↓ 1.5 47,790 1

Hash Join (cost=27,549.71..279,276.84 rows=32,156 width=133) (actual time=595.135..2,452.734 rows=47,790 loops=1)

  • Hash Cond: (urs.risk_group_id = frg.id)
10. 56.153 2,417.529 ↓ 1.5 47,790 1

Hash Join (cost=27,548.42..279,163.62 rows=32,156 width=128) (actual time=595.087..2,417.529 rows=47,790 loops=1)

  • Hash Cond: ((urs.user_id)::text = (""user"".id)::text)
11. 68.318 1,992.457 ↓ 1.5 47,790 1

Hash Join (cost=9,954.33..261,484.34 rows=32,454 width=122) (actual time=225.061..1,992.457 rows=47,790 loops=1)

  • Hash Cond: ((s.user_id)::text = (urs.user_id)::text)
12. 65.781 1,730.877 ↓ 1.5 47,790 1

Nested Loop (cost=2,081.95..253,165.72 rows=32,454 width=101) (actual time=30.672..1,730.877 rows=47,790 loops=1)

13. 39.770 565.926 ↓ 1.5 47,790 1

Nested Loop (cost=2,081.39..192,810.98 rows=32,454 width=93) (actual time=30.581..565.926 rows=47,790 loops=1)

14. 21.875 239.416 ↓ 1.5 47,790 1

Nested Loop (cost=2,080.82..130,716.94 rows=32,454 width=97) (actual time=30.480..239.416 rows=47,790 loops=1)

15. 0.766 35.771 ↑ 1.4 498 1

Hash Join (cost=2,080.25..2,783.21 rows=703 width=4) (actual time=30.362..35.771 rows=498 loops=1)

  • Hash Cond: (pc.parent_id = pcpc.id)
16. 0.963 24.456 ↑ 1.4 498 1

Hash Join (cost=1,386.98..2,088.09 rows=703 width=8) (actual time=19.731..24.456 rows=498 loops=1)

  • Hash Cond: (c.parent_id = pc.id)
17. 1.047 13.844 ↑ 1.4 498 1

Hash Join (cost=693.70..1,392.97 rows=703 width=8) (actual time=9.988..13.844 rows=498 loops=1)

  • Hash Cond: (e.category_id = c.id)
18. 3.050 3.050 ↑ 1.4 498 1

Index Scan using sb_event_dim_start_date_idx on sb_event_dim e (cost=0.43..697.85 rows=703 width=8) (actual time=0.151..3.050 rows=498 loops=1)

  • Index Cond: ((start_date < CURRENT_TIMESTAMP) AND (start_date >= '2019-08-18 21:00:00'::timestamp without time zone) AND (start_date <= '2019-08-19 20:59:00'::timestamp without time zone))
19. 3.408 9.747 ↓ 1.0 10,593 1

Hash (cost=560.90..560.90 rows=10,590 width=8) (actual time=9.747..9.747 rows=10,593 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 542kB
20. 6.339 6.339 ↓ 1.0 10,593 1

Seq Scan on fixtures_category c (cost=0.00..560.90 rows=10,590 width=8) (actual time=0.012..6.339 rows=10,593 loops=1)

21. 3.325 9.649 ↓ 1.0 10,593 1

Hash (cost=560.90..560.90 rows=10,590 width=8) (actual time=9.649..9.649 rows=10,593 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 542kB
22. 6.324 6.324 ↓ 1.0 10,593 1

Seq Scan on fixtures_category pc (cost=0.00..560.90 rows=10,590 width=8) (actual time=0.013..6.324 rows=10,593 loops=1)

23. 3.345 10.549 ↓ 1.0 10,593 1

Hash (cost=560.90..560.90 rows=10,590 width=4) (actual time=10.549..10.549 rows=10,593 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 501kB
24. 7.204 7.204 ↓ 1.0 10,593 1

Seq Scan on fixtures_category pcpc (cost=0.00..560.90 rows=10,590 width=4) (actual time=0.009..7.204 rows=10,593 loops=1)

25. 181.770 181.770 ↑ 7.6 96 498

Index Scan using selection_fact_sb_event_dim_id_idx on selection_fact s (cost=0.56..174.71 rows=727 width=101) (actual time=0.028..0.365 rows=96 loops=498)

  • Index Cond: (sb_event_dim_id = e.id)
  • Filter: ((bet_status)::text <> ALL ('{UNCONFIRMED,DENIED}'::text[]))
  • Rows Removed by Filter: 0
26. 286.740 286.740 ↑ 1.0 1 47,790

Index Only Scan using outcome_dim_id_index on outcome_dim o (cost=0.57..1.90 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=47,790)

  • Index Cond: (id = s.outcome_dim_id)
  • Heap Fetches: 47790
27. 1,099.170 1,099.170 ↑ 1.0 1 47,790

Index Scan using cb_bets_id_index on cb_bets b (cost=0.56..1.85 rows=1 width=45) (actual time=0.022..0.023 rows=1 loops=47,790)

  • Index Cond: ((id)::text = (s.bet_id)::text)
28. 99.675 193.262 ↑ 1.0 218,996 1

Hash (cost=5,133.28..5,133.28 rows=219,128 width=21) (actual time=193.262..193.262 rows=218,996 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 12343kB
29. 93.587 93.587 ↑ 1.0 218,996 1

Seq Scan on fixtures_user_risk_settings urs (cost=0.00..5,133.28 rows=219,128 width=21) (actual time=0.027..93.587 rows=218,996 loops=1)

30. 102.362 368.919 ↓ 1.0 219,025 1

Hash (cost=14,880.15..14,880.15 rows=217,115 width=24) (actual time=368.919..368.919 rows=219,025 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 14154kB
31. 266.557 266.557 ↓ 1.0 219,025 1

Seq Scan on users_cb_users ""user"" (cost=0.00..14,880.15 rows=217,115 width=24) (actual time=0.025..266.557 rows=219,025 loops=1)

32. 0.008 0.019 ↑ 1.0 13 1

Hash (cost=1.13..1.13 rows=13 width=9) (actual time=0.019..0.019 rows=13 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
33. 0.011 0.011 ↑ 1.0 13 1

Seq Scan on fixtures_risk_group frg (cost=0.00..1.13 rows=13 width=9) (actual time=0.007..0.011 rows=13 loops=1)

34. 97.558 214.381 ↑ 1.0 188,197 1

Hash (cost=7,939.46..7,939.46 rows=189,746 width=48) (actual time=214.381..214.381 rows=188,197 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 17057kB
35. 116.823 116.823 ↑ 1.0 188,197 1

Seq Scan on cash_out co (cost=0.00..7,939.46 rows=189,746 width=48) (actual time=0.021..116.823 rows=188,197 loops=1)

36. 0.050 0.121 ↑ 1.0 117 1

Hash (cost=4.17..4.17 rows=117 width=12) (actual time=0.121..0.121 rows=117 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 14kB
37. 0.071 0.071 ↑ 1.0 117 1

Seq Scan on fixtures_country_risk_settings crs (cost=0.00..4.17 rows=117 width=12) (actual time=0.016..0.071 rows=117 loops=1)

38.          

SubPlan (for Hash Left Join)

39. 0.000 0.000 ↑ 1.0 1 95,584

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=95,584)

40.          

SubPlan (for GroupAggregate)

41. 2,739.204 2,739.204 ↑ 1.0 1 5,853

Index Scan using customer_statistics_user_id_index on customer_statistics (cost=0.42..2.70 rows=1 width=32) (actual time=0.076..0.468 rows=1 loops=5,853)

  • Index Cond: ((user_id)::text = (s.user_id)::text)
42.          

Initplan (for Result)

43. 0.048 5,979.235 ↑ 1.0 1 1

Subquery Scan on turnover_summary (cost=1,607.81..1,607.85 rows=1 width=32) (actual time=5,979.234..5,979.235 rows=1 loops=1)

44. 6.174 5,979.187 ↑ 1.0 1 1

Aggregate (cost=1,607.81..1,607.84 rows=1 width=64) (actual time=5,979.187..5,979.187 rows=1 loops=1)

45. 5,973.013 5,973.013 ↑ 5.5 5,853 1

CTE Scan on ""allRows"" (cost=0.00..643.12 rows=32,156 width=40) (actual time=3,017.666..5,973.013 rows=5,853 loops=1)

46. 0.842 3.910 ↑ 1.0 1 1

Aggregate (cost=1,712.20..1,712.21 rows=1 width=32) (actual time=3.910..3.910 rows=1 loops=1)

47. 0.088 3.068 ↑ 1.0 50 1

Subquery Scan on turnover_rows (cost=1,711.32..1,711.94 rows=50 width=1,034) (actual time=2.996..3.068 rows=50 loops=1)

48. 0.011 2.980 ↑ 1.0 50 1

Limit (cost=1,711.32..1,711.44 rows=50 width=1,010) (actual time=2.961..2.980 rows=50 loops=1)

49. 1.771 2.969 ↑ 643.1 50 1

Sort (cost=1,711.32..1,791.71 rows=32,156 width=1,010) (actual time=2.959..2.969 rows=50 loops=1)

  • Sort Key: ""allRows_1"".profit DESC
  • Sort Method: top-N heapsort Memory: 47kB
50. 1.198 1.198 ↑ 5.5 5,853 1

CTE Scan on ""allRows"" ""allRows_1"" (cost=0.00..643.12 rows=32,156 width=1,010) (actual time=0.001..1.198 rows=5,853 loops=1)

Planning time : 14.509 ms
Execution time : 5,988.134 ms