explain.depesz.com

PostgreSQL's explain analyze made readable

Result: k968K

Settings
# exclusive inclusive rows x rows loops node
1. 695.350 1,226,434.418 ↑ 1.7 404,957 1

Merge Right Join (cost=167,378.37..8,191,370.65 rows=706,347 width=273) (actual time=245,527.193..1,226,434.418 rows=404,957 loops=1)

  • Merge Cond: (((facebook_campaign.fb_campaign_id)::text) = (appsfl.campaign_id)::text)
2. 7.581 9.386 ↑ 1.0 1,363 1

Sort (cost=185.80..189.21 rows=1,363 width=28) (actual time=8.938..9.386 rows=1,363 loops=1)

  • Sort Key: ((facebook_campaign.fb_campaign_id)::text)
  • Sort Method: quicksort Memory: 155kB
3. 0.934 1.805 ↑ 1.0 1,363 1

Hash Left Join (cost=1.04..114.84 rows=1,363 width=28) (actual time=0.054..1.805 rows=1,363 loops=1)

  • Hash Cond: (facebook_campaign.ad_account_id = facebook_ad_account.id)
4. 0.856 0.856 ↑ 1.0 1,363 1

Seq Scan on facebook_campaign (cost=0.00..102.63 rows=1,363 width=12) (actual time=0.016..0.856 rows=1,363 loops=1)

5. 0.012 0.015 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=24) (actual time=0.014..0.015 rows=2 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
6. 0.003 0.003 ↑ 1.0 2 1

Seq Scan on facebook_ad_account (cost=0.00..1.02 rows=2 width=24) (actual time=0.002..0.003 rows=2 loops=1)

7. 8,073.426 254,584.970 ↓ 1.0 404,957 1

Materialize (cost=167,192.56..169,211.07 rows=403,701 width=120) (actual time=245,518.227..254,584.970 rows=404,957 loops=1)

8. 6,527.772 246,511.544 ↓ 1.0 404,957 1

Sort (cost=167,192.56..168,201.82 rows=403,701 width=120) (actual time=245,518.216..246,511.544 rows=404,957 loops=1)

  • Sort Key: appsfl.campaign_id
  • Sort Method: external merge Disk: 52,416kB
9. 68,831.545 239,983.772 ↓ 1.0 404,957 1

Hash Right Join (cost=35,823.35..104,762.59 rows=403,701 width=120) (actual time=2,476.013..239,983.772 rows=404,957 loops=1)

  • Hash Cond: (appsfl.user_id = device.user_id)
10. 169,583.647 169,583.647 ↓ 1.0 408,399 1

Seq Scan on appsflyer_install appsfl (cost=0.00..48,508.43 rows=405,843 width=98) (actual time=0.012..169,583.647 rows=408,399 loops=1)

11. 1,148.122 1,568.580 ↓ 1.0 404,845 1

Hash (cost=28,017.09..28,017.09 rows=403,701 width=26) (actual time=1,568.580..1,568.580 rows=404,845 loops=1)

  • Buckets: 65,536 Batches: 8 Memory Usage: 3,687kB
12. 420.458 420.458 ↓ 1.0 404,845 1

Seq Scan on device (cost=0.00..28,017.09 rows=403,701 width=26) (actual time=0.015..420.458 rows=404,845 loops=1)

  • Filter: (type = 2)
  • Rows Removed by Filter: 48,037
13.          

SubPlan (for Merge Right Join)

14. 227.888 971,144.712 ↑ 1.0 1 56,972

Limit (cost=11.24..11.24 rows=1 width=14) (actual time=17.044..17.046 rows=1 loops=56,972)

15. 341.832 970,916.824 ↑ 2.0 1 56,972

Sort (cost=11.24..11.24 rows=2 width=14) (actual time=17.042..17.042 rows=1 loops=56,972)

  • Sort Key: device_app_version.id
  • Sort Method: quicksort Memory: 25kB
16. 970,574.992 970,574.992 ↑ 1.0 2 56,972

Index Scan using u_device_app_version on device_app_version (cost=0.42..11.23 rows=2 width=14) (actual time=12.769..17.036 rows=2 loops=56,972)

  • Index Cond: (device_id = device.id)
Planning time : 4,513.471 ms
Execution time : 1,226,671.710 ms