explain.depesz.com

PostgreSQL's explain analyze made readable

Result: PE2

Settings
# exclusive inclusive rows x rows loops node
1. 768.673 1,591.168 ↓ 118.5 85,287 1

WindowAgg (cost=5,414.08..5,441.08 rows=720 width=176) (actual time=799.942..1,591.168 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, (sum(CASE WHEN (app_usage_day_summaries.is_roaming OR app_usage_day_summaries.is_free) THEN '0'::double precision ELSE app_usage_day_summaries.total_bytes END) OVER (?)), sum(CASE WHEN app_usage_day_summaries.is_roaming THEN app_usage_day_summaries.total_bytes ELSE '0'::double precision END) OVER (?), json_build_array(json_build_object('filter_date', app_usage_day_summaries.filter_date, 'phone_calls_duration_in_seconds_incoming', roaming_days.phone_calls_duration_in_seconds_incoming, 'phone_calls_duration_in_seconds_outgoing', roaming_days.phone_calls_duration_in_seconds_outgoing, 'phone_calls_duration_in_minutes_incoming', roaming_days.phone_calls_duration_in_minutes_incoming, 'phone_calls_duration_in_minutes_outgoing', roaming_days.phone_calls_duration_in_minutes_outgoing, 'text_messages_size_incoming', roaming_days.text_messages_size_incoming, 'text_messages_size_outgoing', roaming_days.text_messages_size_outgoing, 'app_usages_total_bytes', roaming_days.app_usages_total_bytes)), json_build_array(json_build_object('filter_date', app_usage_day_summaries.filter_date, 'total_bytes', app_usage_day_summaries.total_bytes)), app_usage_day_summaries.is_free, (sum(CASE WHEN (app_usage_day_summaries.is_roaming OR app_usage_day_summaries.is_free) THEN '0'::double precision ELSE app_usage_day_summaries.total_bytes END) OVER (?)), app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, app_usage_day_summaries.start_date
  • Buffers: shared hit=260255, temp read=3245 written=3257
2. 184.048 822.495 ↓ 118.5 85,287 1

Sort (cost=5,414.08..5,415.88 rows=720 width=128) (actual time=799.725..822.495 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.start_date, app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_free, roaming_days.phone_calls_duration_in_seconds_incoming, roaming_days.phone_calls_duration_in_seconds_outgoing, roaming_days.phone_calls_duration_in_minutes_incoming, roaming_days.phone_calls_duration_in_minutes_outgoing, roaming_days.text_messages_size_incoming, roaming_days.text_messages_size_outgoing, roaming_days.app_usages_total_bytes, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, (sum(CASE WHEN (app_usage_day_summaries.is_roaming OR app_usage_day_summaries.is_free) THEN '0'::double precision ELSE app_usage_day_summaries.total_bytes END) OVER (?))
  • Sort Key: app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.start_date, app_usage_day_summaries.end_date
  • Sort Method: external merge Disk: 13392kB
  • Buffers: shared hit=260255, temp read=3245 written=3257
3. 84.882 638.447 ↓ 118.5 85,287 1

WindowAgg (cost=5,361.91..5,379.91 rows=720 width=128) (actual time=521.669..638.447 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.start_date, app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_free, roaming_days.phone_calls_duration_in_seconds_incoming, roaming_days.phone_calls_duration_in_seconds_outgoing, roaming_days.phone_calls_duration_in_minutes_incoming, roaming_days.phone_calls_duration_in_minutes_outgoing, roaming_days.text_messages_size_incoming, roaming_days.text_messages_size_outgoing, roaming_days.app_usages_total_bytes, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, sum(CASE WHEN (app_usage_day_summaries.is_roaming OR app_usage_day_summaries.is_free) THEN '0'::double precision ELSE app_usage_day_summaries.total_bytes END) OVER (?)
  • Buffers: shared hit=260255, temp read=1571 written=1577
4. 163.733 553.565 ↓ 118.5 85,287 1

Sort (cost=5,361.91..5,363.71 rows=720 width=120) (actual time=521.463..553.565 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.start_date, app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_free, roaming_days.phone_calls_duration_in_seconds_incoming, roaming_days.phone_calls_duration_in_seconds_outgoing, roaming_days.phone_calls_duration_in_minutes_incoming, roaming_days.phone_calls_duration_in_minutes_outgoing, roaming_days.text_messages_size_incoming, roaming_days.text_messages_size_outgoing, roaming_days.app_usages_total_bytes, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id
  • Sort Key: app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.start_date, app_usage_day_summaries.end_date
  • Sort Method: external merge Disk: 12568kB
  • Buffers: shared hit=260255, temp read=1571 written=1577
5. 20.852 389.832 ↓ 118.5 85,287 1

Nested Loop Left Join (cost=108.44..5,327.74 rows=720 width=120) (actual time=56.006..389.832 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.start_date, app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_free, roaming_days.phone_calls_duration_in_seconds_incoming, roaming_days.phone_calls_duration_in_seconds_outgoing, roaming_days.phone_calls_duration_in_minutes_incoming, roaming_days.phone_calls_duration_in_minutes_outgoing, roaming_days.text_messages_size_incoming, roaming_days.text_messages_size_outgoing, roaming_days.app_usages_total_bytes, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id
  • Inner Unique: true
  • Join Filter: (roaming_days.country_id = roaming_tariffs.country_id)
  • Buffers: shared hit=260255
6. 30.533 198.406 ↓ 118.5 85,287 1

Hash Join (cost=108.16..5,095.71 rows=720 width=92) (actual time=55.956..198.406 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.is_free, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, app_usage_day_summaries.start_date, roaming_tariffs.country_id
  • Inner Unique: true
  • Hash Cond: (app_usage_day_summaries.sim_mnc_id = au_sim_mncs.id)
  • Buffers: shared hit=3506
7. 70.462 166.798 ↓ 118.5 85,287 1

Hash Join (cost=50.69..5,036.35 rows=720 width=92) (actual time=54.869..166.798 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.is_free, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, app_usage_day_summaries.start_date, roaming_tariffs.country_id
  • Inner Unique: true
  • Hash Cond: (app_usage_day_summaries.network_name_id = au_network_names.id)
  • Buffers: shared hit=3490
8. 64.989 96.294 ↓ 118.5 85,287 1

Hash Join (cost=37.54..5,021.26 rows=720 width=92) (actual time=13.726..96.294 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.app_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.network_type_code, app_usage_day_summaries.filter_date, app_usage_day_summaries.total_bytes, app_usage_day_summaries.is_roaming, app_usage_day_summaries.end_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.is_free, app_usage_day_summaries.category_id, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.app_detail_parent_id, app_usage_day_summaries.start_date, roaming_tariffs.country_id
  • Hash Cond: ((app_usage_day_summaries.plan_id = plans.id) AND (app_usage_day_summaries.tariff_country_id = tariffs.country_id))
  • Buffers: shared hit=3489
9. 17.658 17.658 ↑ 1.0 85,287 1

Seq Scan on public.mv_app_usage_day_summaries app_usage_day_summaries (cost=0.00..4,336.87 rows=85,287 width=92) (actual time=0.011..17.658 rows=85,287 loops=1)

  • Output: app_usage_day_summaries.id, app_usage_day_summaries.filter_date, app_usage_day_summaries.carrier_account_id, app_usage_day_summaries.network_name_id, app_usage_day_summaries.is_roaming, app_usage_day_summaries.device_id, app_usage_day_summaries.app_detail_parent_id, app_usage_day_summaries.app_detail_parent_name, app_usage_day_summaries.app_detail_parent_is_group, app_usage_day_summaries.app_detail_parent_label, app_usage_day_summaries.category_id, app_usage_day_summaries.app_id, app_usage_day_summaries.tariff_id, app_usage_day_summaries.sim_mnc_id, app_usage_day_summaries.category_name, app_usage_day_summaries.user_id, app_usage_day_summaries.user_name, app_usage_day_summaries.company_id, app_usage_day_summaries.device_name, app_usage_day_summaries.network_name_name, app_usage_day_summaries.tariff_country_id, app_usage_day_summaries.country_name, app_usage_day_summaries.carrier_account_phone_number, app_usage_day_summaries.carrier_account_name, app_usage_day_summaries.contract_start_date, app_usage_day_summaries.start_date, app_usage_day_summaries.end_date, app_usage_day_summaries.plan_id, app_usage_day_summaries.plan_name, app_usage_day_summaries.plan_rate_type, app_usage_day_summaries.plan_data_cost_in_cents_per_month, app_usage_day_summaries.plan_data_in_bytes_per_month, app_usage_day_summaries.plan_overage_data_mb_rate, app_usage_day_summaries.tariff_name, app_usage_day_summaries.tariff_roaming_data_mb_rate, app_usage_day_summaries.total_bytes, app_usage_day_summaries.network_type_code, app_usage_day_summaries.is_free, app_usage_day_summaries.mnc_id, app_usage_day_summaries.roaming_rule_id
  • Buffers: shared hit=3484
10. 0.180 13.647 ↑ 1.0 243 1

Hash (cost=33.85..33.85 rows=246 width=20) (actual time=13.647..13.647 rows=243 loops=1)

  • Output: plans.id, tariffs.plan_id, tariffs.country_id, roaming_tariffs.plan_id, roaming_tariffs.country_id
  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
  • Buffers: shared hit=5
11. 13.017 13.467 ↑ 1.0 243 1

Hash Join (cost=20.83..33.85 rows=246 width=20) (actual time=0.441..13.467 rows=243 loops=1)

  • Output: plans.id, tariffs.plan_id, tariffs.country_id, roaming_tariffs.plan_id, roaming_tariffs.country_id
  • Hash Cond: (roaming_tariffs.plan_id = plans.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: 58806
  • Buffers: shared hit=5
12. 0.092 0.092 ↑ 1.0 243 1

Seq Scan on public.tariffs roaming_tariffs (cost=0.00..4.43 rows=243 width=16) (actual time=0.015..0.092 rows=243 loops=1)

  • Output: roaming_tariffs.id, roaming_tariffs.name, roaming_tariffs.voice_rate, roaming_tariffs.created_at, roaming_tariffs.updated_at, roaming_tariffs.bill_per_minute, roaming_tariffs.plan_id, roaming_tariffs.country_id, roaming_tariffs.text_message_rate, roaming_tariffs.roaming_voice_rate, roaming_tariffs.roaming_data_mb_rate, roaming_tariffs.roaming_text_message_rate, roaming_tariffs.roaming_rule_id
  • Buffers: shared hit=2
13. 0.110 0.358 ↑ 1.0 243 1

Hash (cost=17.79..17.79 rows=243 width=20) (actual time=0.358..0.358 rows=243 loops=1)

  • Output: plans.id, tariffs.plan_id, tariffs.country_id, tariffs.roaming_rule_id, tariffs.id
  • Buckets: 1024 Batches: 1 Memory Usage: 20kB
  • Buffers: shared hit=3
14. 0.176 0.248 ↑ 1.0 243 1

Hash Join (cost=12.70..17.79 rows=243 width=20) (actual time=0.033..0.248 rows=243 loops=1)

  • Output: plans.id, tariffs.plan_id, tariffs.country_id, tariffs.roaming_rule_id, tariffs.id
  • Inner Unique: true
  • Hash Cond: (tariffs.plan_id = plans.id)
  • Buffers: shared hit=3
15. 0.060 0.060 ↑ 1.0 243 1

Seq Scan on public.tariffs (cost=0.00..4.43 rows=243 width=16) (actual time=0.010..0.060 rows=243 loops=1)

  • Output: tariffs.id, tariffs.name, tariffs.voice_rate, tariffs.created_at, tariffs.updated_at, tariffs.bill_per_minute, tariffs.plan_id, tariffs.country_id, tariffs.text_message_rate, tariffs.roaming_voice_rate, tariffs.roaming_data_mb_rate, tariffs.roaming_text_message_rate, tariffs.roaming_rule_id
  • Buffers: shared hit=2
16. 0.003 0.012 ↑ 120.0 1 1

Hash (cost=11.20..11.20 rows=120 width=4) (actual time=0.011..0.012 rows=1 loops=1)

  • Output: plans.id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1
17. 0.009 0.009 ↑ 120.0 1 1

Seq Scan on public.plans (cost=0.00..11.20 rows=120 width=4) (actual time=0.008..0.009 rows=1 loops=1)

  • Output: plans.id
  • Buffers: shared hit=1
18. 0.009 0.042 ↑ 14.0 10 1

Hash (cost=11.40..11.40 rows=140 width=4) (actual time=0.042..0.042 rows=10 loops=1)

  • Output: au_network_names.id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1
19. 0.033 0.033 ↑ 14.0 10 1

Seq Scan on public.network_names au_network_names (cost=0.00..11.40 rows=140 width=4) (actual time=0.029..0.033 rows=10 loops=1)

  • Output: au_network_names.id
  • Buffers: shared hit=1
20. 0.538 1.075 ↑ 1.0 1,843 1

Hash (cost=34.43..34.43 rows=1,843 width=4) (actual time=1.074..1.075 rows=1,843 loops=1)

  • Output: au_sim_mncs.id
  • Buckets: 2048 Batches: 1 Memory Usage: 81kB
  • Buffers: shared hit=16
21. 0.537 0.537 ↑ 1.0 1,843 1

Seq Scan on public.mncs au_sim_mncs (cost=0.00..34.43 rows=1,843 width=4) (actual time=0.023..0.537 rows=1,843 loops=1)

  • Output: au_sim_mncs.id
  • Buffers: shared hit=16
22. 170.574 170.574 ↑ 1.0 1 85,287

Index Only Scan using roaming_days_json on public.roaming_days (cost=0.28..0.31 rows=1 width=44) (actual time=0.002..0.002 rows=1 loops=85,287)

  • Output: roaming_days.filter_date, roaming_days.carrier_account_id, roaming_days.country_id, roaming_days.phone_calls_duration_in_seconds_incoming, roaming_days.phone_calls_duration_in_seconds_outgoing, roaming_days.phone_calls_duration_in_minutes_incoming, roaming_days.phone_calls_duration_in_minutes_outgoing, roaming_days.text_messages_size_incoming, roaming_days.text_messages_size_outgoing, roaming_days.app_usages_total_bytes
  • Index Cond: ((roaming_days.filter_date = app_usage_day_summaries.filter_date) AND (roaming_days.carrier_account_id = app_usage_day_summaries.carrier_account_id))
  • Heap Fetches: 85287
  • Buffers: shared hit=256749
Planning time : 7.538 ms