explain.depesz.com

PostgreSQL's explain analyze made readable

Result: btQf

Settings
# exclusive inclusive rows x rows loops node
1. 0.319 23,226.151 ↓ 11.0 11 1

Sort (cost=817.31..817.31 rows=1 width=2,309) (actual time=23,226.134..23,226.151 rows=11 loops=1)

  • Sort Key: rec.ts_rec DESC
  • Sort Method: quicksort Memory: 69kB
2. 0.125 23,225.832 ↓ 11.0 11 1

Nested Loop Left Join (cost=396.56..817.30 rows=1 width=2,309) (actual time=2,938.101..23,225.832 rows=11 loops=1)

  • Join Filter: (rec.event_id = events.event_id)
  • Rows Removed by Join Filter: 130
3. 0.117 23,225.641 ↓ 11.0 11 1

Nested Loop (cost=396.56..813.49 rows=1 width=2,107) (actual time=2,938.085..23,225.641 rows=11 loops=1)

  • Join Filter: (vc.company_id = c.company_id)
  • Rows Removed by Join Filter: 121
4. 0.124 23,225.392 ↓ 11.0 11 1

Nested Loop (cost=396.56..812.31 rows=1 width=1,887) (actual time=2,938.058..23,225.392 rows=11 loops=1)

  • Join Filter: (vbsu.vehicle_id = v_d.vehicle_id)
  • Rows Removed by Join Filter: 121
5. 0.094 23,222.067 ↓ 11.0 11 1

Nested Loop Left Join (cost=395.32..807.77 rows=1 width=1,753) (actual time=2,935.473..23,222.067 rows=11 loops=1)

6. 0.119 23,221.511 ↓ 11.0 11 1

Nested Loop (cost=394.90..801.49 rows=1 width=1,574) (actual time=2,935.349..23,221.511 rows=11 loops=1)

  • Join Filter: (d.model_id = mod.model_id)
  • Rows Removed by Join Filter: 33
7. 0.155 23,221.359 ↓ 11.0 11 1

Nested Loop (cost=394.90..800.37 rows=1 width=1,102) (actual time=2,935.326..23,221.359 rows=11 loops=1)

  • Join Filter: (d.device_status_id = dst.device_status_id)
  • Rows Removed by Join Filter: 66
8. 154.054 23,221.138 ↓ 11.0 11 1

Hash Join (cost=394.90..799.19 rows=1 width=990) (actual time=2,935.283..23,221.138 rows=11 loops=1)

  • Hash Cond: (rec.record_id = d.record_id)
9. 170.391 23,061.984 ↓ 66.2 294,367 1

Merge Join (cost=13.47..401.09 rows=4,446 width=914) (actual time=0.456..23,061.984 rows=294,367 loops=1)

  • Merge Cond: (v_d.vehicle_id = veh.vehicle_id)
10. 112.309 22,891.369 ↓ 28.5 294,367 1

Nested Loop (cost=4.58..733,927.64 rows=10,344 width=719) (actual time=0.239..22,891.369 rows=294,367 loops=1)

11. 0.076 0.249 ↓ 11.0 11 1

Merge Join (cost=4.58..4.71 rows=1 width=144) (actual time=0.149..0.249 rows=11 loops=1)

  • Merge Cond: (v_d.vehicle_id = vc.vehicle_id)
12. 0.047 0.075 ↓ 11.0 11 1

Sort (cost=2.41..2.42 rows=1 width=90) (actual time=0.067..0.075 rows=11 loops=1)

  • Sort Key: v_d.vehicle_id
  • Sort Method: quicksort Memory: 26kB
13. 0.028 0.028 ↓ 11.0 11 1

Seq Scan on vehicles_devices v_d (cost=0.00..2.40 rows=1 width=90) (actual time=0.016..0.028 rows=11 loops=1)

  • Filter: ((to_date_ved IS NULL) AND (vehicle_id = ANY ('{8,9,10,11,13,15,16,17,18,60,71}'::integer[])))
  • Rows Removed by Filter: 53
14. 0.063 0.098 ↑ 1.1 30 1

Sort (cost=2.12..2.20 rows=32 width=54) (actual time=0.077..0.098 rows=30 loops=1)

  • Sort Key: vc.vehicle_id
  • Sort Method: quicksort Memory: 35kB
15. 0.035 0.035 ↓ 2.2 72 1

Seq Scan on vehicles_companies vc (cost=0.00..1.32 rows=32 width=54) (actual time=0.021..0.035 rows=72 loops=1)

  • Filter: (to_date_veco IS NULL)
  • Rows Removed by Filter: 1
16. 51.744 22,778.811 ↑ 1.1 26,761 11

Append (cost=0.00..733,632.30 rows=29,064 width=579) (actual time=0.042..2,070.801 rows=26,761 loops=11)

17. 0.055 0.055 ↓ 0.0 0 11

Seq Scan on records_data rec (cost=0.00..1.01 rows=1 width=1,276) (actual time=0.005..0.005 rows=0 loops=11)

  • Filter: (v_d.vehicle_device_id = vehicle_device_id)
  • Rows Removed by Filter: 1
18. 7,087.223 7,087.223 ↑ 1.3 6,379 11

Index Scan using idx_ts_rec__vehicle_device__records_data_202007 on records_data_202007 rec_1 (cost=0.42..20,659.69 rows=8,573 width=1,281) (actual time=0.674..644.293 rows=6,379 loops=11)

  • Index Cond: (vehicle_device_id = v_d.vehicle_device_id)
19. 3,925.680 3,925.680 ↑ 1.3 4,123 11

Index Scan using idx_ts_rec__vehicle_device__records_data_202008 on records_data_202008 rec_2 (cost=0.42..11,898.95 rows=5,370 width=1,464) (actual time=0.029..356.880 rows=4,123 loops=11)

  • Index Cond: (vehicle_device_id = v_d.vehicle_device_id)
20. 7,930.032 7,930.032 ↓ 1.1 11,684 11

Index Scan using idx_ts_rec__vehicle_device__records_data_202009 on records_data_202009 rec_3 (cost=0.56..459,110.43 rows=10,997 width=565) (actual time=15.358..720.912 rows=11,684 loops=11)

  • Index Cond: (vehicle_device_id = v_d.vehicle_device_id)
21. 7.139 7.139 ↓ 0.0 0 11

Seq Scan on records_data_202002 rec_4 (cost=0.00..13.62 rows=1 width=252) (actual time=0.649..0.649 rows=0 loops=11)

  • Filter: (v_d.vehicle_device_id = vehicle_device_id)
  • Rows Removed by Filter: 1
22. 4.686 4.686 ↓ 0.0 0 11

Seq Scan on records_data_202006 rec_5 (cost=0.00..13.62 rows=1 width=252) (actual time=0.426..0.426 rows=0 loops=11)

  • Filter: (v_d.vehicle_device_id = vehicle_device_id)
  • Rows Removed by Filter: 3
23. 3,772.252 3,772.252 ↓ 1.1 4,574 11

Index Scan using idx_ts_rec__vehicle_device__records_data_202010 on records_data_202010 rec_6 (cost=0.43..241,789.64 rows=4,121 width=580) (actual time=0.146..342.932 rows=4,574 loops=11)

  • Index Cond: (vehicle_device_id = v_d.vehicle_device_id)
24. 0.096 0.224 ↑ 2.4 30 1

Sort (cost=8.89..9.07 rows=71 width=195) (actual time=0.209..0.224 rows=30 loops=1)

  • Sort Key: veh.vehicle_id
  • Sort Method: quicksort Memory: 40kB
25. 0.128 0.128 ↓ 1.0 73 1

Seq Scan on vehicles veh (cost=0.00..6.71 rows=71 width=195) (actual time=0.008..0.128 rows=73 loops=1)

26. 1.103 5.100 ↑ 1.0 1,693 1

Hash (cost=360.21..360.21 rows=1,697 width=84) (actual time=5.099..5.100 rows=1,693 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 224kB
27. 3.997 3.997 ↑ 1.0 1,697 1

Seq Scan on devices d (cost=0.00..360.21 rows=1,697 width=84) (actual time=0.033..3.997 rows=1,697 loops=1)

  • Filter: (device_status_id <> 7)
28. 0.066 0.066 ↑ 1.1 7 11

Seq Scan on device_status dst (cost=0.00..1.08 rows=8 width=116) (actual time=0.006..0.006 rows=7 loops=11)

29. 0.033 0.033 ↑ 1.2 4 11

Seq Scan on models mod (cost=0.00..1.05 rows=5 width=476) (actual time=0.002..0.003 rows=4 loops=11)

30. 0.462 0.462 ↑ 1.0 1 11

Index Scan using pk_position on positions (cost=0.42..6.29 rows=1 width=183) (actual time=0.042..0.042 rows=1 loops=11)

  • Index Cond: (rec.position_id = position_id)
31. 2.747 3.201 ↓ 2.4 12 11

Hash Join (cost=1.24..4.47 rows=5 width=142) (actual time=0.252..0.291 rows=12 loops=11)

  • Hash Cond: (vbsu.business_unit_id = bsu.business_unit_id)
32. 0.418 0.418 ↓ 1.1 89 11

Seq Scan on vehicles_business_units vbsu (cost=0.00..2.98 rows=84 width=54) (actual time=0.014..0.038 rows=89 loops=11)

  • Filter: (to_date_vbsu IS NULL)
  • Rows Removed by Filter: 1
33. 0.009 0.036 ↓ 4.0 4 1

Hash (cost=1.23..1.23 rows=1 width=88) (actual time=0.036..0.036 rows=4 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
34. 0.027 0.027 ↓ 4.0 4 1

Seq Scan on business_units bsu (cost=0.00..1.23 rows=1 width=88) (actual time=0.023..0.027 rows=4 loops=1)

  • Filter: (company_id = 2)
  • Rows Removed by Filter: 26
35. 0.132 0.132 ↓ 1.5 12 11

Seq Scan on companies c (cost=0.00..1.08 rows=8 width=224) (actual time=0.008..0.012 rows=12 loops=11)

36. 0.066 0.066 ↑ 2.8 13 11

Seq Scan on events (cost=0.00..3.36 rows=36 width=206) (actual time=0.003..0.006 rows=13 loops=11)

Planning time : 14.299 ms