explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Xwna

Settings
# exclusive inclusive rows x rows loops node
1. 0.017 9,814.539 ↓ 153.0 153 1

Unique (cost=278,518.57..278,518.58 rows=1 width=4) (actual time=9,814.517..9,814.539 rows=153 loops=1)

2. 0.268 9,814.522 ↓ 153.0 153 1

Sort (cost=278,518.57..278,518.58 rows=1 width=4) (actual time=9,814.516..9,814.522 rows=153 loops=1)

  • Sort Key: h3.id_habitante
  • Sort Method: quicksort Memory: 32kB
3. 458.505 9,814.254 ↓ 153.0 153 1

Nested Loop (cost=278,506.19..278,518.56 rows=1 width=4) (actual time=3,642.062..9,814.254 rows=153 loops=1)

  • Join Filter: (ph.cd_hoja = ph_1.cd_hoja)
  • Rows Removed by Join Filter: 10080363
4. 1.774 2,316.021 ↓ 996.0 996 1

Nested Loop (cost=139,247.04..139,259.37 rows=1 width=8) (actual time=1,111.031..2,316.021 rows=996 loops=1)

5. 0.000 2,302.295 ↓ 996.0 996 1

Nested Loop (cost=139,246.74..139,254.80 rows=1 width=12) (actual time=1,111.017..2,302.295 rows=996 loops=1)

6. 112.146 1,165.054 ↓ 142,991.0 142,991 1

HashAggregate (cost=139,246.32..139,246.33 rows=1 width=12) (actual time=1,110.798..1,165.054 rows=142,991 loops=1)

7. 386.990 1,052.908 ↓ 144,961.0 144,961 1

Hash Join (cost=49,307.09..139,246.32 rows=1 width=12) (actual time=432.183..1,052.908 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.924 234.274 ↓ 1.5 142,991 1

Subquery Scan on max1 (cost=0.42..26,840.04 rows=97,836 width=19) (actual time=0.074..234.274 rows=142,991 loops=1)

9. 101.514 224.350 ↓ 1.5 142,991 1

GroupAggregate (cost=0.42..25,861.67 rows=97,836 width=19) (actual time=0.074..224.350 rows=142,991 loops=1)

10. 122.836 122.836 ↑ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h (cost=0.42..20,130.42 rows=475,289 width=19) (actual time=0.067..122.836 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. 134.833 431.644 ↑ 1.0 475,289 1

Hash (cost=36,550.89..36,550.89 rows=475,289 width=27) (actual time=431.644..431.644 rows=475,289 loops=1)

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

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

13. 1,143.928 1,143.928 ↓ 0.0 0 142,991

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

  • Index Cond: (id_registro = (max(h1.id_registro)))
  • Filter: ((tipo_mov <> 'B'::bpchar) AND (pos_fecha_nac >= '1958-09-12 00:00:00'::timestamp without time zone) AND (pos_fecha_nac <= '1959-09-11 00:00:00'::timestamp without time zone))
  • Rows Removed by Filter: 1
14. 11.952 11.952 ↑ 1.0 1 996

Index Scan using phhojapadronal_pkey on phhojapadronal ph (cost=0.29..4.56 rows=1 width=12) (actual time=0.010..0.012 rows=1 loops=996)

  • Index Cond: (id_registro = h3.pos_id_hoja_hist)
15. 4,557.839 7,039.728 ↓ 10,121.0 10,121 996

HashAggregate (cost=139,259.15..139,259.17 rows=1 width=4) (actual time=2.537..7.068 rows=10,121 loops=996)

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

Nested Loop (cost=139,247.04..139,259.15 rows=1 width=4) (actual time=1,100.507..2,481.889 rows=75,793 loops=1)

17. 0.000 2,284.003 ↓ 75,793.0 75,793 1

Nested Loop (cost=139,246.74..139,254.80 rows=1 width=8) (actual time=1,100.473..2,284.003 rows=75,793 loops=1)

18. 108.780 1,150.886 ↓ 142,991.0 142,991 1

HashAggregate (cost=139,246.32..139,246.33 rows=1 width=12) (actual time=1,100.443..1,150.886 rows=142,991 loops=1)

19. 384.915 1,042.106 ↓ 144,961.0 144,961 1

Hash Join (cost=49,307.09..139,246.32 rows=1 width=12) (actual time=440.600..1,042.106 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.652 217.128 ↓ 1.5 142,991 1

Subquery Scan on max1_1 (cost=0.42..26,840.04 rows=97,836 width=19) (actual time=0.052..217.128 rows=142,991 loops=1)

21. 98.405 207.476 ↓ 1.5 142,991 1

GroupAggregate (cost=0.42..25,861.67 rows=97,836 width=19) (actual time=0.052..207.476 rows=142,991 loops=1)

22. 109.071 109.071 ↑ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h_1 (cost=0.42..20,130.42 rows=475,289 width=19) (actual time=0.044..109.071 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. 135.220 440.063 ↑ 1.0 475,289 1

Hash (cost=36,550.89..36,550.89 rows=475,289 width=27) (actual time=440.063..440.063 rows=475,289 loops=1)

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

Seq Scan on phistorico h1_1 (cost=0.00..36,550.89 rows=475,289 width=27) (actual time=0.010..304.843 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 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)