explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZY4s

Settings
# exclusive inclusive rows x rows loops node
1. 609.305 11,754.695 ↓ 1.1 575,204 1

Sort (cost=2,220,998.61..2,222,352.85 rows=541,696 width=171) (actual time=11,631.113..11,754.695 rows=575,204 loops=1)

  • Sort Key: betslips.status_updated
  • Sort Method: quicksort Memory: 176,020kB
2. 2,091.623 11,145.390 ↓ 1.1 575,204 1

Nested Loop (cost=12,186.58..2,169,409.86 rows=541,696 width=171) (actual time=904.205..11,145.390 rows=575,204 loops=1)

3. 104.435 7,375.435 ↓ 1.0 559,444 1

Hash Left Join (cost=12,186.15..1,418,638.15 rows=535,952 width=138) (actual time=904.144..7,375.435 rows=559,444 loops=1)

  • Hash Cond: (betslips._location = locations.id)
4. 410.626 7,270.897 ↓ 1.0 559,444 1

Hash Join (cost=12,177.26..1,416,307.84 rows=535,952 width=69) (actual time=904.014..7,270.897 rows=559,444 loops=1)

  • Hash Cond: (betslips._client = clients.id)
5. 6,694.291 6,694.291 ↓ 1.0 559,444 1

Seq Scan on betslips (cost=0.00..1,396,761.23 rows=535,952 width=28) (actual time=737.649..6,694.291 rows=559,444 loops=1)

  • Filter: ((NOT is_test) AND (status_updated >= '2020-09-11 00:00:00+00'::timestamp with time zone) AND (status_updated <= '2020-10-15 00:00:00+00'::timestamp with time zone))
  • Rows Removed by Filter: 15,683,105
6. 80.005 165.980 ↑ 1.0 238,945 1

Hash (cost=9,190.45..9,190.45 rows=238,945 width=49) (actual time=165.980..165.980 rows=238,945 loops=1)

  • Buckets: 262,144 Batches: 1 Memory Usage: 21,831kB
7. 85.975 85.975 ↑ 1.0 238,945 1

Seq Scan on clients (cost=0.00..9,190.45 rows=238,945 width=49) (actual time=0.007..85.975 rows=238,945 loops=1)

8. 0.062 0.103 ↑ 1.0 217 1

Hash (cost=6.17..6.17 rows=217 width=77) (actual time=0.103..0.103 rows=217 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 31kB
9. 0.041 0.041 ↑ 1.0 217 1

Seq Scan on locations (cost=0.00..6.17 rows=217 width=77) (actual time=0.008..0.041 rows=217 loops=1)

10. 1,678.332 1,678.332 ↑ 6.0 1 559,444

Index Scan using idx_bets_betslip on bets (cost=0.44..1.30 rows=6 width=37) (actual time=0.003..0.003 rows=1 loops=559,444)

  • Index Cond: (_betslip = betslips.id)
  • Filter: ((status <> 'open'::bets_status) AND ((status = 'lost'::bets_status) OR ((((stake - COALESCE(win_amount, '0'::numeric)) - COALESCE(return_amount, '0'::numeric)) - COALESCE((((bonus_info -> 'early_cashout'::text) ->> 'value'::text))::numeric, '0'::numeric)) > '0'::numeric)))
  • Rows Removed by Filter: 0
Planning time : 0.950 ms
Execution time : 11,792.097 ms