explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 13O5

Settings
# exclusive inclusive rows x rows loops node
1. 0.422 73,699.137 ↓ 4,247.0 4,247 1

Unique (cost=283,936.76..283,936.77 rows=1 width=4) (actual time=73,698.462..73,699.137 rows=4,247 loops=1)

2. 6.107 73,698.715 ↓ 4,247.0 4,247 1

Sort (cost=283,936.76..283,936.77 rows=1 width=4) (actual time=73,698.461..73,698.715 rows=4,247 loops=1)

  • Sort Key: h3.id_habitante
  • Sort Method: quicksort Memory: 392kB
3. 8,071.996 73,692.608 ↓ 4,247.0 4,247 1

Nested Loop (cost=283,924.59..283,936.75 rows=1 width=4) (actual time=3,642.536..73,692.608 rows=4,247 loops=1)

  • Join Filter: (ph.cd_hoja = ph_1.cd_hoja)
  • Rows Removed by Join Filter: 177123374
4. 18.064 2,214.489 ↓ 17,501.0 17,501 1

Nested Loop (cost=141,956.24..141,968.37 rows=1 width=8) (actual time=1,092.512..2,214.489 rows=17,501 loops=1)

5. 93.681 2,108.920 ↓ 17,501.0 17,501 1

Nested Loop (cost=141,955.94..141,964.00 rows=1 width=12) (actual time=1,092.506..2,108.920 rows=17,501 loops=1)

6. 121.394 1,157.293 ↓ 142,991.0 142,991 1

HashAggregate (cost=141,955.52..141,955.53 rows=1 width=12) (actual time=1,092.453..1,157.293 rows=142,991 loops=1)

7. 371.504 1,035.899 ↓ 144,961.0 144,961 1

Hash Join (cost=49,308.53..141,955.52 rows=1 width=12) (actual time=435.029..1,035.899 rows=144,961 loops=1)

  • Hash Cond: ((max1.max_fecha_real = h1.pos_fecha_real_ult) AND ((max1.cd_prov_ent)::text = (h1.cd_prov_ent)::text) AND ((max1.cd_mun_ent)::text = (h1.cd_mun_ent)::text) AND (max1.id_habitante = h1.id_habitante))
8. 9.643 229.945 ↓ 1.4 142,991 1

Subquery Scan on max1 (cost=0.42..26,879.92 rows=99,752 width=19) (actual time=0.084..229.945 rows=142,991 loops=1)

9. 99.426 220.302 ↓ 1.4 142,991 1

GroupAggregate (cost=0.42..25,882.40 rows=99,752 width=19) (actual time=0.083..220.302 rows=142,991 loops=1)

10. 120.876 120.876 ↑ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h (cost=0.42..20,131.51 rows=475,337 width=19) (actual time=0.075..120.876 rows=475,289 loops=1)

  • Index Cond: ((cd_prov_ent = '46'::text) AND (cd_mun_ent = '131'::text) AND (pos_fecha_real_ult <= '2019-09-11 00:00:00'::timestamp without time zone))
  • Heap Fetches: 0
11. 133.078 434.450 ↑ 1.0 475,289 1

Hash (cost=36,551.37..36,551.37 rows=475,337 width=27) (actual time=434.450..434.450 rows=475,289 loops=1)

  • Buckets: 2048 Batches: 32 Memory Usage: 938kB
12. 301.372 301.372 ↑ 1.0 475,289 1

Seq Scan on phistorico h1 (cost=0.00..36,551.37 rows=475,337 width=27) (actual time=0.011..301.372 rows=475,289 loops=1)

13. 857.946 857.946 ↓ 0.0 0 142,991

Index Scan using indx_phco_id_prov_mun_tipo_fecha_nac on phistorico h3 (cost=0.42..8.45 rows=1 width=20) (actual time=0.006..0.006 rows=0 loops=142,991)

  • Index Cond: ((id_registro = (max(h1.id_registro))) AND ((cd_prov_ent)::text = '46'::text) AND ((cd_mun_ent)::text = '131'::text) AND (pos_fecha_nac < '1958-09-12 00:00:00'::timestamp without time zone))
  • Filter: (tipo_mov <> 'B'::bpchar)
  • Rows Removed by Filter: 0
14. 87.505 87.505 ↑ 1.0 1 17,501

Index Scan using phhojapadronal_pkey on phhojapadronal ph (cost=0.29..4.35 rows=1 width=12) (actual time=0.004..0.005 rows=1 loops=17,501)

  • Index Cond: (id_registro = h3.pos_id_hoja_hist)
15. 60,904.497 63,406.123 ↓ 10,121.0 10,121 17,501

HashAggregate (cost=141,968.35..141,968.37 rows=1 width=4) (actual time=0.146..3.623 rows=10,121 loops=17,501)

  • Filter: (count(*) = 1)
  • Rows Removed by Filter: 20892
16. 36.644 2,501.626 ↓ 75,793.0 75,793 1

Nested Loop (cost=141,956.24..141,968.35 rows=1 width=4) (actual time=1,098.936..2,501.626 rows=75,793 loops=1)

17. 19.994 2,313.396 ↓ 75,793.0 75,793 1

Nested Loop (cost=141,955.94..141,964.00 rows=1 width=8) (actual time=1,098.930..2,313.396 rows=75,793 loops=1)

18. 107.987 1,149.474 ↓ 142,991.0 142,991 1

HashAggregate (cost=141,955.52..141,955.53 rows=1 width=12) (actual time=1,098.874..1,149.474 rows=142,991 loops=1)

19. 385.879 1,041.487 ↓ 144,961.0 144,961 1

Hash Join (cost=49,308.53..141,955.52 rows=1 width=12) (actual time=439.879..1,041.487 rows=144,961 loops=1)

  • Hash Cond: ((max1_1.max_fecha_real = h1_1.pos_fecha_real_ult) AND ((max1_1.cd_prov_ent)::text = (h1_1.cd_prov_ent)::text) AND ((max1_1.cd_mun_ent)::text = (h1_1.cd_mun_ent)::text) AND (max1_1.id_habitante = h1_1. (...)
20. 9.546 216.278 ↓ 1.4 142,991 1

Subquery Scan on max1_1 (cost=0.42..26,879.92 rows=99,752 width=19) (actual time=0.073..216.278 rows=142,991 loops=1)

21. 98.268 206.732 ↓ 1.4 142,991 1

GroupAggregate (cost=0.42..25,882.40 rows=99,752 width=19) (actual time=0.072..206.732 rows=142,991 loops=1)

22. 108.464 108.464 ↑ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h_1 (cost=0.42..20,131.51 rows=475,337 width=19) (actual time=0.039..108.464 rows=475,289 loops=1)

  • Index Cond: ((cd_prov_ent = '46'::text) AND (cd_mun_ent = '131'::text) AND (pos_fecha_real_ult <= '2019-09-11 00:00:00'::timestamp without time zone))
  • Heap Fetches: 0
23. 132.692 439.330 ↑ 1.0 475,289 1

Hash (cost=36,551.37..36,551.37 rows=475,337 width=27) (actual time=439.330..439.330 rows=475,289 loops=1)

  • Buckets: 2048 Batches: 32 Memory Usage: 938kB
24. 306.638 306.638 ↑ 1.0 475,289 1

Seq Scan on phistorico h1_1 (cost=0.00..36,551.37 rows=475,337 width=27) (actual time=0.011..306.638 rows=475,289 loops=1)

25. 1,143.928 1,143.928 ↑ 1.0 1 142,991

Index Scan using indx_phco_id_prov_mun_tipo_fecha_nac on phistorico h3_1 (cost=0.42..8.45 rows=1 width=16) (actual time=0.008..0.008 rows=1 loops=142,991)

  • Index Cond: (id_registro = (max(h1_1.id_registro)))
  • Filter: (tipo_mov <> 'B'::bpchar)
  • Rows Removed by Filter: 0
26. 151.586 151.586 ↑ 1.0 1 75,793

Index Scan using phhojapadronal_pkey on phhojapadronal ph_1 (cost=0.29..4.34 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=75,793)

  • Index Cond: (id_registro = h3_1.pos_id_hoja_hist)
Total runtime : 73,703.234 ms