explain.depesz.com

PostgreSQL's explain analyze made readable

Result: AU6C : Optimization for: plan #BlhN

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.508 16.884 ↑ 9.0 4 1

GroupAggregate (cost=2,485.61..7,529.80 rows=36 width=36) (actual time=15.641..16.884 rows=4 loops=1)

  • Group Key: accounts.currency
2. 0.159 15.584 ↓ 2.6 192 1

Sort (cost=2,485.61..2,485.79 rows=74 width=29) (actual time=15.555..15.584 rows=192 loops=1)

  • Sort Key: accounts.currency
  • Sort Method: quicksort Memory: 40kB
3. 0.080 15.425 ↓ 2.6 192 1

Nested Loop Left Join (cost=731.95..2,483.31 rows=74 width=29) (actual time=5.118..15.425 rows=192 loops=1)

4. 0.148 15.153 ↓ 2.6 192 1

Nested Loop (cost=731.67..2,137.32 rows=74 width=29) (actual time=5.111..15.153 rows=192 loops=1)

5. 1.911 14.621 ↓ 2.6 192 1

Hash Join (cost=731.38..2,021.56 rows=74 width=33) (actual time=5.096..14.621 rows=192 loops=1)

  • Hash Cond: (balance_transactions.reference_id = bonus_issues.id)
6. 1.925 8.392 ↓ 2.6 11,687 1

Append (cost=146.36..1,424.79 rows=4,476 width=8) (actual time=0.699..8.392 rows=11,687 loops=1)

  • -> Index Scan using casino_balance_transactions_2_reference_type_reference_id_idx30 on casino_balance_transactions_2020_w32 (cost=0.14..8.17 rows=1 wi
  • -> Index Scan using casino_balance_transactions_2_reference_type_reference_id_idx31 on casino_balance_transactions_2020_w33 (cost=0.14..8.17 rows=1 wi
7. 3.397 3.397 ↓ 4.1 7,796 1

Bitmap Heap Scan on balance_transactions (cost=146.36..1,017.76 rows=1,890 width=8) (actual time=0.698..3.397 rows=7,796 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=352
  • -> Bitmap Index Scan on index_balance_transactions_on_action_full (cost=0.00..145.89 rows=7,680 width=0) (actual time=0.637..0.637 rows=7,796 loop
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
8. 0.135 0.135 ↓ 7.0 14 1

Seq Scan on casino_balance_transactions_2020_w02 (cost=0.00..4.47 rows=2 width=8) (actual time=0.107..0.135 rows=14 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 127
9. 0.055 0.055 ↓ 10.6 53 1

Bitmap Heap Scan on casino_balance_transactions_2020_w03 (cost=4.68..18.60 rows=5 width=8) (actual time=0.035..0.055 rows=53 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=4
  • -> Bitmap Index Scan on index_casino_balance_transactions_2020_w03_on_action_full (cost=0.00..4.67 rows=53 width=0) (actual time=0.026..0.026 ro
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
10. 0.084 0.084 ↓ 4.5 18 1

Seq Scan on casino_balance_transactions_2020_w04 (cost=0.00..4.84 rows=4 width=8) (actual time=0.053..0.084 rows=18 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 144
11. 0.103 0.103 ↓ 3.9 27 1

Seq Scan on casino_balance_transactions_2020_w05 (cost=0.00..8.87 rows=7 width=8) (actual time=0.048..0.103 rows=27 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 251
12. 0.082 0.082 ↓ 11.0 11 1

Seq Scan on casino_balance_transactions_2020_w06 (cost=0.00..6.61 rows=1 width=8) (actual time=0.072..0.082 rows=11 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 195
13. 0.087 0.087 ↓ 2.0 43 1

Seq Scan on casino_balance_transactions_2020_w07 (cost=0.00..6.68 rows=21 width=8) (actual time=0.046..0.087 rows=43 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 167
14. 0.064 0.064 ↓ 1.3 36 1

Seq Scan on casino_balance_transactions_2020_w08 (cost=0.00..3.59 rows=27 width=8) (actual time=0.045..0.064 rows=36 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 55
15. 0.087 0.087 ↓ 2.3 37 1

Seq Scan on casino_balance_transactions_2020_w09 (cost=0.00..6.12 rows=16 width=8) (actual time=0.048..0.087 rows=37 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 141
16. 0.095 0.095 ↓ 2.5 48 1

Seq Scan on casino_balance_transactions_2020_w10 (cost=0.00..7.03 rows=19 width=8) (actual time=0.050..0.095 rows=48 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 182
17. 0.096 0.096 ↓ 1.8 58 1

Seq Scan on casino_balance_transactions_2020_w11 (cost=0.00..6.69 rows=32 width=8) (actual time=0.051..0.096 rows=58 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 153
18. 0.098 0.098 ↓ 1.6 23 1

Seq Scan on casino_balance_transactions_2020_w12 (cost=0.00..3.93 rows=14 width=8) (actual time=0.078..0.098 rows=23 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 87
19. 0.049 0.049 ↓ 2.3 35 1

Seq Scan on casino_balance_transactions_2020_w13 (cost=0.00..5.99 rows=15 width=8) (actual time=0.017..0.049 rows=35 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 136
20. 0.051 0.051 ↓ 2.8 39 1

Seq Scan on casino_balance_transactions_2020_w14 (cost=0.00..6.61 rows=14 width=8) (actual time=0.011..0.051 rows=39 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 167
21. 0.166 0.166 ↓ 1.1 269 1

Seq Scan on casino_balance_transactions_2020_w15 (cost=0.00..18.31 rows=244 width=8) (actual time=0.048..0.166 rows=269 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 320
22. 0.032 0.032 ↓ 1.9 39 1

Seq Scan on casino_balance_transactions_2020_w16 (cost=0.00..3.79 rows=21 width=8) (actual time=0.013..0.032 rows=39 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 63
23. 0.095 0.095 ↓ 1.9 103 1

Seq Scan on casino_balance_transactions_2020_w17 (cost=0.00..11.28 rows=53 width=8) (actual time=0.009..0.095 rows=103 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 256
24. 0.058 0.058 ↓ 1.8 70 1

Seq Scan on casino_balance_transactions_2020_w18 (cost=0.00..6.69 rows=40 width=8) (actual time=0.009..0.058 rows=70 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 141
25. 0.147 0.147 ↓ 2.3 194 1

Seq Scan on casino_balance_transactions_2020_w19 (cost=0.00..17.01 rows=84 width=8) (actual time=0.011..0.147 rows=194 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 378
26. 0.036 0.036 ↓ 1.8 32 1

Seq Scan on casino_balance_transactions_2020_w20 (cost=0.00..4.36 rows=18 width=8) (actual time=0.010..0.036 rows=32 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 103
27. 0.050 0.050 ↓ 1.9 35 1

Seq Scan on casino_balance_transactions_2020_w21 (cost=0.00..6.46 rows=18 width=8) (actual time=0.015..0.050 rows=35 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 163
28. 0.050 0.050 ↓ 3.4 57 1

Bitmap Heap Scan on casino_balance_transactions_2020_w22 (cost=4.70..10.70 rows=17 width=8) (actual time=0.026..0.050 rows=57 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=4
  • -> Bitmap Index Scan on index_casino_balance_transactions_2020_w22_on_action_full (cost=0.00..4.70 rows=57 width=0) (actual time=0.020..0.020 ro
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
29. 0.055 0.055 ↓ 5.2 52 1

Bitmap Heap Scan on casino_balance_transactions_2020_w23 (cost=4.67..12.57 rows=10 width=8) (actual time=0.020..0.055 rows=52 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=5
  • -> Bitmap Index Scan on index_casino_balance_transactions_2020_w23_on_action_full (cost=0.00..4.66 rows=52 width=0) (actual time=0.015..0.015 ro
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
30. 0.050 0.050 ↓ 2.3 62 1

Bitmap Heap Scan on casino_balance_transactions_2020_w24 (cost=4.74..12.83 rows=27 width=8) (actual time=0.022..0.050 rows=62 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=5
  • -> Bitmap Index Scan on casino_balance_transactions_2020_w24_action_idx (cost=0.00..4.74 rows=62 width=0) (actual time=0.016..0.016 rows=62 loop
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
31. 0.062 0.062 ↓ 3.1 93 1

Bitmap Heap Scan on casino_balance_transactions_2020_w25 (cost=4.98..12.61 rows=30 width=8) (actual time=0.024..0.062 rows=93 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=6
  • -> Bitmap Index Scan on casino_balance_transactions_2020_w25_action_idx (cost=0.00..4.97 rows=93 width=0) (actual time=0.017..0.017 rows=93 loop
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
32. 0.088 0.088 ↓ 4.5 90 1

Bitmap Heap Scan on casino_balance_transactions_2020_w26 (cost=4.96..16.53 rows=20 width=8) (actual time=0.022..0.088 rows=90 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=9
  • -> Bitmap Index Scan on casino_balance_transactions_2020_w26_action_idx (cost=0.00..4.95 rows=90 width=0) (actual time=0.016..0.017 rows=90 loop
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
33. 0.051 0.051 ↓ 1.9 40 1

Seq Scan on casino_balance_transactions_2020_w27 (cost=0.00..6.20 rows=21 width=8) (actual time=0.010..0.051 rows=40 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 143
34. 0.780 0.780 ↓ 1.2 1,938 1

Seq Scan on casino_balance_transactions_2020_w28 (cost=0.00..73.95 rows=1,583 width=8) (actual time=0.012..0.780 rows=1,938 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 516
35. 0.094 0.094 ↓ 1.2 148 1

Bitmap Heap Scan on casino_balance_transactions_2020_w29 (cost=5.42..40.01 rows=119 width=8) (actual time=0.028..0.094 rows=148 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=10
  • -> Bitmap Index Scan on casino_balance_transactions_2020_w29_action_idx (cost=0.00..5.39 rows=148 width=0) (actual time=0.022..0.022 rows=148 lo
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
36. 0.079 0.079 ↓ 2.3 132 1

Bitmap Heap Scan on casino_balance_transactions_2020_w30 (cost=5.28..15.59 rows=57 width=8) (actual time=0.026..0.079 rows=132 loops=1)

  • Recheck Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text))
  • Heap Blocks: exact=7
  • -> Bitmap Index Scan on casino_balance_transactions_2020_w30_action_idx (cost=0.00..5.27 rows=132 width=0) (actual time=0.019..0.019 rows=132 lo
  • Index Cond: (action = 'issued_bonus'::balance_transactions_actions_type)
37. 0.091 0.091 ↓ 2.1 95 1

Seq Scan on casino_balance_transactions_2020_w31 (cost=0.00..9.43 rows=45 width=8) (actual time=0.010..0.091 rows=95 loops=1)

  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'BonusIssue'::text) AND (action = 'issued
  • Rows Removed by Filter: 215
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND (action = 'issued_bonus'::balance_transactions_actions_type))
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND (action = 'issued_bonus'::balance_transactions_actions_type))
  • Rows Removed by Filter: 2
38. 0.067 4.318 ↑ 1.0 192 1

Hash (cost=582.61..582.61 rows=193 width=33) (actual time=4.318..4.318 rows=192 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 21kB
39. 4.251 4.251 ↑ 1.0 192 1

Seq Scan on bonus_issues (cost=0.00..582.61 rows=193 width=33) (actual time=0.076..4.251 rows=192 loops=1)

  • Filter: (((stage)::text = ANY ('{wait,handle_bets}'::text[])) OR (((stage)::text <> 'issued'::text) AND (updated_at >= '2020-08-11 12:57:48'::time
  • Rows Removed by Filter: 11,557
40. 0.384 0.384 ↑ 1.0 1 192

Index Scan using accounts_pkey on accounts (cost=0.28..1.56 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=192)

  • Index Cond: (id = bonus_issues.account_id)
41. 0.192 0.192 ↓ 0.0 0 192

Index Scan using payments_pkey on payments (cost=0.29..4.68 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=192)

  • Index Cond: (bonus_issues.payment_id = id)
42.          

SubPlan (for GroupAggregate)

43. 0.384 0.384 ↑ 1.0 1 192

Aggregate (cost=8.50..8.51 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=192)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions (cost=0.29..8.50 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: (((action)::text = ANY ('{bet,win}'::text[])) AND (dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone))
44. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=8.50..8.51 rows=1 width=32) (never executed)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_1 (cost=0.29..8.50 rows=1 width=8) (never ex
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: ((dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((action)::text = 'bet'::text))
45. 0.284 0.284 ↑ 1.0 1 142

Aggregate (cost=8.50..8.51 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=142)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_2 (cost=0.29..8.50 rows=1 width=8) (actual t
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: (((action)::text = ANY ('{bet,win}'::text[])) AND (dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone))
46. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=8.50..8.51 rows=1 width=32) (never executed)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_3 (cost=0.29..8.50 rows=1 width=8) (never ex
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: ((dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((action)::text = 'bet'::text))
47. 0.100 0.100 ↑ 1.0 1 50

Aggregate (cost=8.50..8.51 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=50)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_4 (cost=0.29..8.50 rows=1 width=8) (actual t
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: (((action)::text = ANY ('{bet,win}'::text[])) AND (dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone))
48. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=8.50..8.51 rows=1 width=32) (never executed)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_5 (cost=0.29..8.50 rows=1 width=8) (never ex
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: ((dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((action)::text = 'bet'::text))
49. 0.024 0.024 ↑ 1.0 1 4

Aggregate (cost=8.50..8.51 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=4)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_6 (cost=0.29..8.50 rows=1 width=8) (actual t
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: (((action)::text = ANY ('{bet,win}'::text[])) AND (dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone))
50. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=8.50..8.51 rows=1 width=32) (never executed)

  • -> Index Scan using index_dense_balance_transactions_on_bonus_issue_id on dense_balance_transactions dense_balance_transactions_7 (cost=0.29..8.50 rows=1 width=8) (never ex
  • Index Cond: (bonus_issue_id = bonus_issues.id)
  • Filter: ((dense_created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((action)::text = 'bet'::text))
Planning time : 16.279 ms
Execution time : 17.491 ms