explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BlhN

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.493 30.302 ↑ 9.0 4 1

GroupAggregate (cost=3,068.29..9,611.97 rows=36 width=36) (actual time=29.095..30.302 rows=4 loops=1)

  • Group Key: accounts.currency
2. 0.159 29.005 ↓ 2.0 192 1

Sort (cost=3,068.29..3,068.53 rows=96 width=29) (actual time=28.978..29.005 rows=192 loops=1)

  • Sort Key: accounts.currency
  • Sort Method: quicksort Memory: 40kB
3. 0.040 28.846 ↓ 2.0 192 1

Nested Loop Left Join (cost=1,882.49..3,065.13 rows=96 width=29) (actual time=23.983..28.846 rows=192 loops=1)

4. 0.062 28.614 ↓ 2.0 192 1

Nested Loop (cost=1,882.21..2,616.27 rows=96 width=29) (actual time=23.965..28.614 rows=192 loops=1)

5. 0.129 27.784 ↓ 2.0 192 1

Hash Join (cost=1,881.92..2,466.11 rows=96 width=33) (actual time=23.923..27.784 rows=192 loops=1)

  • Hash Cond: (bonus_issues.id = balance_transactions.reference_id)
6. 3.814 3.814 ↑ 1.0 192 1

Seq Scan on bonus_issues (cost=0.00..582.61 rows=193 width=33) (actual time=0.050..3.814 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'::timestamp
  • Rows Removed by Filter: 11,557
7. 2.203 23.841 ↓ 58.4 11,687 1

Hash (cost=1,879.42..1,879.42 rows=200 width=8) (actual time=23.841..23.841 rows=11,687 loops=1)

  • Buckets: 16,384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 585kB
8. 7.081 21.638 ↓ 58.4 11,687 1

HashAggregate (cost=1,877.42..1,879.42 rows=200 width=8) (actual time=19.450..21.638 rows=11,687 loops=1)

  • Group Key: balance_transactions.reference_id
9. 1.592 14.557 ↓ 1.2 11,687 1

Append (cost=366.53..1,853.50 rows=9,570 width=8) (actual time=5.633..14.557 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.
  • -> Index Scan using casino_balance_transactions_2_reference_type_reference_id_idx31 on casino_balance_transactions_2020_w33 (cost=0.14..8.
10. 9.807 9.807 ↓ 1.3 7,796 1

Bitmap Heap Scan on balance_transactions (cost=366.53..1,366.38 rows=5,842 width=8) (actual time=5.632..9.807 rows=7,796 loops=1)

  • Recheck Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Rows Removed by Filter: 7,183
  • Heap Blocks: exact=443
  • -> Bitmap Index Scan on index_balance_transactions_on_reference_type_and_reference_id (cost=0.00..365.06 rows=15,020 width=0) (actual
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
11. 0.132 0.132 ↓ 1.4 14 1

Seq Scan on casino_balance_transactions_2020_w02 (cost=0.00..4.47 rows=10 width=8) (actual time=0.111..0.132 rows=14 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 127
12. 0.101 0.101 ↓ 1.6 53 1

Bitmap Heap Scan on casino_balance_transactions_2020_w03 (cost=4.98..19.59 rows=34 width=8) (actual time=0.084..0.101 rows=53 loops=1)

  • Recheck Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Rows Removed by Filter: 39
  • Heap Blocks: exact=5
  • -> Bitmap Index Scan on casino_balance_transactions_20_reference_type_reference_id_idx1 (cost=0.00..4.97 rows=92 width=0) (actual ti
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
13. 0.067 0.067 ↑ 1.2 18 1

Seq Scan on casino_balance_transactions_2020_w04 (cost=0.00..4.84 rows=22 width=8) (actual time=0.045..0.067 rows=18 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 144
14. 0.059 0.059 ↑ 1.2 27 1

Seq Scan on casino_balance_transactions_2020_w05 (cost=0.00..8.87 rows=32 width=8) (actual time=0.028..0.059 rows=27 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 251
15. 0.121 0.121 ↑ 1.2 11 1

Seq Scan on casino_balance_transactions_2020_w06 (cost=0.00..6.61 rows=13 width=8) (actual time=0.109..0.121 rows=11 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 195
16. 0.087 0.087 ↑ 1.3 43 1

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

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 167
17. 0.051 0.051 ↑ 1.2 36 1

Seq Scan on casino_balance_transactions_2020_w08 (cost=0.00..3.59 rows=42 width=8) (actual time=0.035..0.051 rows=36 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 55
18. 0.067 0.067 ↑ 1.2 37 1

Seq Scan on casino_balance_transactions_2020_w09 (cost=0.00..6.12 rows=45 width=8) (actual time=0.034..0.067 rows=37 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 141
19. 0.095 0.095 ↑ 1.1 48 1

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

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 182
20. 0.113 0.113 ↑ 1.0 58 1

Seq Scan on casino_balance_transactions_2020_w11 (cost=0.00..6.69 rows=60 width=8) (actual time=0.057..0.113 rows=58 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 153
21. 0.039 0.039 ↑ 1.3 23 1

Seq Scan on casino_balance_transactions_2020_w12 (cost=0.00..3.93 rows=31 width=8) (actual time=0.023..0.039 rows=23 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 87
22. 0.094 0.094 ↓ 1.0 35 1

Seq Scan on casino_balance_transactions_2020_w13 (cost=0.00..5.99 rows=34 width=8) (actual time=0.032..0.094 rows=35 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 136
23. 0.060 0.060 ↑ 1.1 39 1

Seq Scan on casino_balance_transactions_2020_w14 (cost=0.00..6.61 rows=42 width=8) (actual time=0.025..0.060 rows=39 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 167
24. 0.099 0.099 ↑ 1.0 269 1

Seq Scan on casino_balance_transactions_2020_w15 (cost=0.00..18.31 rows=270 width=8) (actual time=0.026..0.099 rows=269 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 320
25. 0.037 0.037 ↓ 1.1 39 1

Seq Scan on casino_balance_transactions_2020_w16 (cost=0.00..3.79 rows=36 width=8) (actual time=0.021..0.037 rows=39 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 63
26. 0.056 0.056 ↑ 1.0 103 1

Seq Scan on casino_balance_transactions_2020_w17 (cost=0.00..11.28 rows=105 width=8) (actual time=0.006..0.056 rows=103 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 256
27. 0.095 0.095 ↑ 1.2 70 1

Seq Scan on casino_balance_transactions_2020_w18 (cost=0.00..6.69 rows=82 width=8) (actual time=0.023..0.095 rows=70 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 141
28. 0.123 0.123 ↓ 1.2 194 1

Seq Scan on casino_balance_transactions_2020_w19 (cost=0.00..17.01 rows=156 width=8) (actual time=0.008..0.123 rows=194 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 378
29. 0.040 0.040 ↑ 1.1 32 1

Seq Scan on casino_balance_transactions_2020_w20 (cost=0.00..4.36 rows=36 width=8) (actual time=0.014..0.040 rows=32 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 103
30. 0.053 0.053 ↑ 1.4 35 1

Seq Scan on casino_balance_transactions_2020_w21 (cost=0.00..6.46 rows=48 width=8) (actual time=0.021..0.053 rows=35 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 163
31. 0.062 0.062 ↓ 1.3 57 1

Seq Scan on casino_balance_transactions_2020_w22 (cost=0.00..11.67 rows=45 width=8) (actual time=0.010..0.062 rows=57 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 324
32. 0.066 0.066 ↓ 1.6 52 1

Bitmap Heap Scan on casino_balance_transactions_2020_w23 (cost=5.02..13.73 rows=32 width=8) (actual time=0.047..0.066 rows=52 loops=1)

  • Recheck Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Rows Removed by Filter: 46
  • Heap Blocks: exact=5
  • -> Bitmap Index Scan on casino_balance_transactions_2_reference_type_reference_id_idx21 (cost=0.00..5.01 rows=98 width=0) (actual ti
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
33. 0.076 0.076 ↑ 1.2 62 1

Seq Scan on casino_balance_transactions_2020_w24 (cost=0.00..15.80 rows=75 width=8) (actual time=0.008..0.076 rows=62 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 441
34. 0.068 0.068 ↓ 1.1 93 1

Seq Scan on casino_balance_transactions_2020_w25 (cost=0.00..14.49 rows=83 width=8) (actual time=0.006..0.068 rows=93 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 392
35. 0.087 0.087 ↓ 1.3 90 1

Bitmap Heap Scan on casino_balance_transactions_2020_w26 (cost=9.54..22.44 rows=68 width=8) (actual time=0.039..0.087 rows=90 loops=1)

  • Recheck Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Rows Removed by Filter: 76
  • Heap Blocks: exact=9
  • -> Bitmap Index Scan on casino_balance_transactions_2_reference_type_reference_id_idx24 (cost=0.00..9.52 rows=166 width=0) (actual t
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
36. 0.062 0.062 ↑ 1.0 40 1

Seq Scan on casino_balance_transactions_2020_w27 (cost=0.00..6.20 rows=40 width=8) (actual time=0.029..0.062 rows=40 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 143
37. 0.482 0.482 ↓ 1.1 1,938 1

Seq Scan on casino_balance_transactions_2020_w28 (cost=0.00..73.95 rows=1,703 width=8) (actual time=0.008..0.482 rows=1,938 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 516
38. 0.516 0.516 ↑ 1.8 148 1

Seq Scan on casino_balance_transactions_2020_w29 (cost=0.00..77.25 rows=266 width=8) (actual time=0.006..0.516 rows=148 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 2,438
39. 0.101 0.101 ↓ 1.0 132 1

Seq Scan on casino_balance_transactions_2020_w30 (cost=0.00..19.09 rows=131 width=8) (actual time=0.009..0.101 rows=132 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 502
40. 0.049 0.049 ↓ 1.2 95 1

Seq Scan on casino_balance_transactions_2020_w31 (cost=0.00..9.43 rows=79 width=8) (actual time=0.006..0.049 rows=95 loops=1)

  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone) AND ((reference_type)::text = 'Bonus
  • Rows Removed by Filter: 215
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Index Cond: ((reference_type)::text = 'BonusIssue'::text)
  • Filter: ((amount_cents > 0) AND (created_at < '2020-08-11 12:57:48'::timestamp without time zone))
  • Rows Removed by Filter: 2
41. 0.768 0.768 ↑ 1.0 1 192

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

  • Index Cond: (id = bonus_issues.account_id)
42. 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)
43.          

SubPlan (for GroupAggregate)

44. 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.001..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))
45. 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))
46. 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))
47. 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))
48. 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))
49. 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))
50. 0.036 0.036 ↑ 1.0 1 4

Aggregate (cost=8.50..8.51 rows=1 width=32) (actual time=0.009..0.009 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))
51. 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 : 10.779 ms
Execution time : 31.216 ms