explain.depesz.com

PostgreSQL's explain analyze made readable

Result: W7sM

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 3.370 ↓ 0.0 0 1

Subquery Scan on phone_tmp_roaming (cost=26.36..26.68 rows=1 width=1,350) (actual time=3.370..3.370 rows=0 loops=1)

  • Filter: ('[2018-03-01,2018-04-01)'::daterange @> phone_tmp_roaming.filter_date)
  • Rows Removed by Filter: 5
2. 0.147 3.365 ↓ 5.0 5 1

WindowAgg (cost=26.36..26.66 rows=1 width=1,354) (actual time=3.308..3.365 rows=5 loops=1)

3. 0.018 3.218 ↓ 5.0 5 1

Sort (cost=26.36..26.37 rows=1 width=1,310) (actual time=3.217..3.218 rows=5 loops=1)

  • Sort Key: phone_calls.carrier_account_id, (period_start(phone_calls.filter_date, carrier_accounts.contract_start_date))
  • Sort Method: quicksort Memory: 26kB
4. 0.248 3.200 ↓ 5.0 5 1

Nested Loop Left Join (cost=5.46..26.35 rows=1 width=1,310) (actual time=2.909..3.200 rows=5 loops=1)

  • Join Filter: ((roaming_days.carrier_account_id = phone_calls.carrier_account_id) AND (roaming_days.country_id = roaming_tariffs.country_id) AND (roaming_days.filter_date = phone_calls.filter_date))
  • Rows Removed by Join Filter: 23
5. 0.012 2.812 ↓ 5.0 5 1

Nested Loop (cost=4.04..24.48 rows=1 width=1,234) (actual time=2.723..2.812 rows=5 loops=1)

6. 0.014 2.755 ↓ 5.0 5 1

Nested Loop (cost=3.76..20.18 rows=1 width=1,234) (actual time=2.677..2.755 rows=5 loops=1)

  • Join Filter: (tariffs.country_id = pc_mncs.country_id)
  • Rows Removed by Join Filter: 5
7. 0.023 2.691 ↓ 10.0 10 1

Nested Loop (cost=3.48..11.87 rows=1 width=1,238) (actual time=2.635..2.691 rows=10 loops=1)

8. 2.447 2.638 ↓ 5.0 10 1

Hash Join (cost=3.34..5.64 rows=2 width=1,245) (actual time=2.617..2.638 rows=10 loops=1)

  • Hash Cond: (carrier_accounts.plan_id = tariffs.plan_id)
9. 0.024 0.053 ↑ 1.0 5 1

Hash Join (cost=1.11..3.37 rows=5 width=1,229) (actual time=0.040..0.053 rows=5 loops=1)

  • Hash Cond: (carrier_accounts.id = phone_calls.carrier_account_id)
10. 0.016 0.016 ↑ 1.0 15 1

Seq Scan on carrier_accounts (cost=0.00..2.15 rows=15 width=12) (actual time=0.014..0.016 rows=15 loops=1)

11. 0.005 0.013 ↑ 1.0 5 1

Hash (cost=1.05..1.05 rows=5 width=1,221) (actual time=0.013..0.013 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
12. 0.008 0.008 ↑ 1.0 5 1

Seq Scan on phone_calls (cost=0.00..1.05 rows=5 width=1,221) (actual time=0.007..0.008 rows=5 loops=1)

13. 0.004 0.138 ↓ 2.0 4 1

Hash (cost=2.21..2.21 rows=2 width=16) (actual time=0.138..0.138 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
14. 0.056 0.134 ↓ 2.0 4 1

Hash Join (cost=1.09..2.21 rows=2 width=16) (actual time=0.130..0.134 rows=4 loops=1)

  • Hash Cond: (tariffs.plan_id = roaming_tariffs.plan_id)
  • Join Filter: CASE WHEN (tariffs.roaming_rule_id IS NULL) THEN (roaming_tariffs.id = tariffs.id) ELSE (roaming_tariffs.roaming_rule_id = tariffs.roaming_rule_id) END
  • Rows Removed by Join Filter: 4
15. 0.052 0.052 ↑ 1.0 4 1

Seq Scan on tariffs (cost=0.00..1.04 rows=4 width=16) (actual time=0.051..0.052 rows=4 loops=1)

16. 0.006 0.026 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=16) (actual time=0.026..0.026 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
17. 0.020 0.020 ↑ 1.0 4 1

Seq Scan on tariffs roaming_tariffs (cost=0.00..1.04 rows=4 width=16) (actual time=0.017..0.020 rows=4 loops=1)

18. 0.030 0.030 ↑ 1.0 1 10

Index Scan using plans_pkey on plans (cost=0.14..3.09 rows=1 width=9) (actual time=0.003..0.003 rows=1 loops=10)

  • Index Cond: (id = carrier_accounts.plan_id)
19. 0.050 0.050 ↑ 1.0 1 10

Index Scan using mncs_pkey on mncs pc_mncs (cost=0.28..8.30 rows=1 width=8) (actual time=0.004..0.005 rows=1 loops=10)

  • Index Cond: (id = phone_calls.mnc_id)
20. 0.045 0.045 ↑ 1.0 1 5

Index Only Scan using mncs_pkey on mncs pc_sim_mncs (cost=0.28..4.30 rows=1 width=4) (actual time=0.009..0.009 rows=1 loops=5)

  • Index Cond: (id = phone_calls.sim_mnc_id)
  • Heap Fetches: 0
21. 0.128 0.140 ↓ 1.2 6 5

HashAggregate (cost=1.42..1.48 rows=5 width=92) (actual time=0.012..0.028 rows=6 loops=5)

  • Group Key: roaming_days.carrier_account_id, roaming_days.country_id, roaming_days.filter_date
22. 0.012 0.012 ↑ 1.0 12 1

Seq Scan on roaming_days (cost=0.00..1.12 rows=12 width=44) (actual time=0.010..0.012 rows=12 loops=1)

Planning time : 18.607 ms