explain.depesz.com

PostgreSQL's explain analyze made readable

Result: v4ry

Settings
# exclusive inclusive rows x rows loops node
1. 0.016 8,342.884 ↓ 153.0 153 1

Unique (cost=286,233.10..286,233.11 rows=1 width=4) (actual time=8,342.864..8,342.884 rows=153 loops=1)

2. 0.207 8,342.868 ↓ 153.0 153 1

Sort (cost=286,233.10..286,233.11 rows=1 width=4) (actual time=8,342.863..8,342.868 rows=153 loops=1)

  • Sort Key: h3.id_habitante
  • Sort Method: quicksort Memory: 32kB
3. 460.620 8,342.661 ↓ 153.0 153 1

Nested Loop (cost=247,233.83..286,233.09 rows=1 width=4) (actual time=3,122.389..8,342.661 rows=153 loops=1)

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

Nested Loop (cost=104,117.42..143,116.64 rows=1 width=8) (actual time=1,121.802..1,941.897 rows=996 loops=1)

5. 0.000 1,934.959 ↓ 996.0 996 1

Nested Loop (cost=104,117.12..143,112.06 rows=1 width=12) (actual time=1,121.777..1,934.959 rows=996 loops=1)

6. 40.438 1,672.743 ↓ 142,991.0 142,991 1

GroupAggregate (cost=104,116.70..143,103.59 rows=1 width=12) (actual time=1,120.511..1,672.743 rows=142,991 loops=1)

7. 106.206 1,632.305 ↓ 144,961.0 144,961 1

Merge Join (cost=104,116.70..143,103.57 rows=1 width=12) (actual time=1,120.498..1,632.305 rows=144,961 loops=1)

  • Merge Cond: (h.id_habitante = h1.id_habitante)
  • Join Filter: ((h1.pos_fecha_real_ult = (max(h.pos_fecha_real_ult))) AND ((h1.cd_prov_ent)::text = (h.cd_prov_ent)::text) AND ((h1.cd_mun_ent)::text = (h.cd_mun_ent)::text))
  • Rows Removed by Join Filter: 330328
8. 103.935 236.091 ↓ 1.4 142,991 1

GroupAggregate (cost=0.42..25,870.72 rows=98,760 width=19) (actual time=0.073..236.091 rows=142,991 loops=1)

9. 132.156 132.156 ↓ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h (cost=0.42..20,130.29 rows=475,283 width=19) (actual time=0.066..132.156 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
10. 38.868 1,290.008 ↓ 1.0 475,289 1

Materialize (cost=104,116.28..106,492.69 rows=475,283 width=27) (actual time=1,120.410..1,290.008 rows=475,289 loops=1)

11. 369.666 1,251.140 ↓ 1.0 475,289 1

Sort (cost=104,116.28..105,304.49 rows=475,283 width=27) (actual time=1,120.406..1,251.140 rows=475,289 loops=1)

  • Sort Key: h1.id_habitante
  • Sort Method: external merge Disk: 19016kB
12. 881.474 881.474 ↓ 1.0 475,289 1

Seq Scan on phistorico h1 (cost=0.00..36,550.83 rows=475,283 width=27) (actual time=0.010..881.474 rows=475,289 loops=1)

13. 285.982 285.982 ↓ 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.002..0.002 rows=0 loops=142,991)

  • Index Cond: ((id_registro = (max(h1.id_registro))) 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))
  • Filter: (tipo_mov <> 'B'::bpchar)
  • Rows Removed by Filter: 0
14. 5.976 5.976 ↑ 1.0 1 996

Index Scan using phhojapadronal_pkey on phhojapadronal ph (cost=0.29..4.57 rows=1 width=12) (actual time=0.004..0.006 rows=1 loops=996)

  • Index Cond: (id_registro = h3.pos_id_hoja_hist)
15. 4,088.020 5,940.144 ↓ 10,121.0 10,121 996

HashAggregate (cost=143,116.41..143,116.43 rows=1 width=4) (actual time=1.899..5.964 rows=10,121 loops=996)

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

Nested Loop (cost=104,117.42..143,116.41 rows=1 width=4) (actual time=537.003..1,852.124 rows=75,793 loops=1)

17. 33.704 1,689.304 ↓ 75,793.0 75,793 1

Nested Loop (cost=104,117.12..143,112.05 rows=1 width=8) (actual time=536.996..1,689.304 rows=75,793 loops=1)

18. 43.815 1,083.636 ↓ 142,991.0 142,991 1

GroupAggregate (cost=104,116.70..143,103.59 rows=1 width=12) (actual time=536.967..1,083.636 rows=142,991 loops=1)

19. 114.121 1,039.821 ↓ 144,961.0 144,961 1

Merge Join (cost=104,116.70..143,103.57 rows=1 width=12) (actual time=536.952..1,039.821 rows=144,961 loops=1)

  • Merge Cond: (h_1.id_habitante = h1_1.id_habitante)
  • Join Filter: ((h1_1.pos_fecha_real_ult = (max(h_1.pos_fecha_real_ult))) AND ((h1_1.cd_prov_ent)::text = (h_1.cd_prov_ent)::text) AND ((h1_1.cd_mun_ent)::text = (h_1.cd_mun_ent)::text))
  • Rows Removed by Join Filter: 330328
20. 110.367 240.177 ↓ 1.4 142,991 1

GroupAggregate (cost=0.42..25,870.72 rows=98,760 width=19) (actual time=0.047..240.177 rows=142,991 loops=1)

21. 129.810 129.810 ↓ 1.0 475,289 1

Index Only Scan using idx_phco_habpk_idreg_posfreal on phistorico h_1 (cost=0.42..20,130.29 rows=475,283 width=19) (actual time=0.040..129.810 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
22. 40.025 685.523 ↓ 1.0 475,289 1

Materialize (cost=104,116.28..106,492.69 rows=475,283 width=27) (actual time=536.893..685.523 rows=475,289 loops=1)

23. 336.218 645.498 ↓ 1.0 475,289 1

Sort (cost=104,116.28..105,304.49 rows=475,283 width=27) (actual time=536.890..645.498 rows=475,289 loops=1)

  • Sort Key: h1_1.id_habitante
  • Sort Method: external merge Disk: 19016kB
24. 309.280 309.280 ↓ 1.0 475,289 1

Seq Scan on phistorico h1_1 (cost=0.00..36,550.83 rows=475,283 width=27) (actual time=0.013..309.280 rows=475,289 loops=1)

25. 571.964 571.964 ↑ 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.004..0.004 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)