explain.depesz.com

PostgreSQL's explain analyze made readable

Result: cakO

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Insert on device_stats (cost=17,238,557.89..17,415,170.05 rows=941,932 width=150) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Subquery Scan on *SELECT* (cost=17,238,557.89..17,415,170.05 rows=941,932 width=150) (actual rows= loops=)

3. 0.000 0.000 ↓ 0.0

Unique (cost=17,238,557.89..17,391,621.75 rows=941,932 width=177) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Sort (cost=17,238,557.89..17,250,332.04 rows=4,709,657 width=177) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (max(anon_1.dr) OVER (?)), (max(anon_1.altitude) OVER (?)), (count(anon_1.device_id) OVER (?)), (first_value(anon_1.name) OVER (?)), (first_value(anon_1."timestamp") OVER (?)), (first_value(anon_1."timestamp") OVER (?)), (first_value(anon_1.aircraft_type) OVER (?)), (first_value(anon_1.stealth) OVER (?)), (first_value(anon_1.software_version) OVER (?)), (first_value(anon_1.hardware_version) OVER (?)), (first_value(anon_1.real_address) OVER (?))
5. 0.000 0.000 ↓ 0.0

WindowAgg (cost=15,396,649.93..15,490,843.07 rows=4,709,657 width=177) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Sort (cost=15,396,649.93..15,408,424.07 rows=4,709,657 width=182) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.real_address IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
7. 0.000 0.000 ↓ 0.0

WindowAgg (cost=13,554,741.97..13,648,935.11 rows=4,709,657 width=182) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Sort (cost=13,554,741.97..13,566,516.11 rows=4,709,657 width=180) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.hardware_version IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
9. 0.000 0.000 ↓ 0.0

WindowAgg (cost=11,712,834.01..11,807,027.15 rows=4,709,657 width=180) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Sort (cost=11,712,834.01..11,724,608.15 rows=4,709,657 width=176) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.software_version IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
11. 0.000 0.000 ↓ 0.0

WindowAgg (cost=9,918,076.05..10,012,269.19 rows=4,709,657 width=176) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Sort (cost=9,918,076.05..9,929,850.19 rows=4,709,657 width=175) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.stealth IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
13. 0.000 0.000 ↓ 0.0

WindowAgg (cost=8,123,318.09..8,217,511.23 rows=4,709,657 width=175) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Sort (cost=8,123,318.09..8,135,092.23 rows=4,709,657 width=173) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.aircraft_type IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
15. 0.000 0.000 ↓ 0.0

WindowAgg (cost=6,328,560.13..6,422,753.27 rows=4,709,657 width=173) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Sort (cost=6,328,560.13..6,340,334.27 rows=4,709,657 width=165) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1."timestamp" IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END) DESC NULLS LAST
17. 0.000 0.000 ↓ 0.0

WindowAgg (cost=4,580,941.92..4,675,135.06 rows=4,709,657 width=165) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Sort (cost=4,580,941.92..4,592,716.06 rows=4,709,657 width=157) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1."timestamp" IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END)
19. 0.000 0.000 ↓ 0.0

WindowAgg (cost=3,097,320.65..3,191,513.79 rows=4,709,657 width=157) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

Sort (cost=3,097,320.65..3,109,094.80 rows=4,709,657 width=125) (actual rows= loops=)

  • Sort Key: anon_1.device_id, (CASE WHEN (anon_1.name IS NULL) THEN NULL::timestamp without time zone ELSE anon_1."timestamp" END)
21. 0.000 0.000 ↓ 0.0

WindowAgg (cost=1,623,265.08..1,858,747.93 rows=4,709,657 width=125) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Subquery Scan on anon_1 (cost=1,623,265.08..1,764,554.79 rows=4,709,657 width=105) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

WindowAgg (cost=1,623,265.08..1,717,458.22 rows=4,709,657 width=349) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Sort (cost=1,623,265.08..1,635,039.23 rows=4,709,657 width=45) (actual rows= loops=)

  • Sort Key: aircraft_beacons.device_id, aircraft_beacons.receiver_id
25. 0.000 0.000 ↓ 0.0

Seq Scan on aircraft_beacons (cost=0.00..761,834.96 rows=4,709,657 width=45) (actual rows= loops=)

  • Filter: ((device_id IS NOT NULL) AND ("timestamp" >= '2019-04-12 00:00:00'::timestamp without time zone) AND ("timestamp" <= '2019-04-12 23:59:59'::timestamp without time zone) AND ((error_count = 0) OR (error_count IS NULL)))