explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YXvK

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 10,530.681 ↓ 14.0 14 1

Unique (cost=103,325.21..103,325.22 rows=1 width=4) (actual time=10,530.678..10,530.681 rows=14 loops=1)

2. 0.030 10,530.678 ↓ 14.0 14 1

Sort (cost=103,325.21..103,325.22 rows=1 width=4) (actual time=10,530.677..10,530.678 rows=14 loops=1)

  • Sort Key: h3.id_habitante
  • Sort Method: quicksort Memory: 25kB
3. 591.922 10,530.648 ↓ 14.0 14 1

Nested Loop (cost=103,316.99..103,325.20 rows=1 width=4) (actual time=5,779.467..10,530.648 rows=14 loops=1)

  • Join Filter: (ph.cd_hoja = ph_1.cd_hoja)
  • Rows Removed by Join Filter: 13042491
4. 0.474 2,759.452 ↓ 4,717.0 4,717 1

Nested Loop (cost=51,654.45..51,662.62 rows=1 width=8) (actual time=2,593.242..2,759.452 rows=4,717 loops=1)

5. 14.239 2,744.827 ↓ 4,717.0 4,717 1

Nested Loop (cost=51,654.16..51,662.21 rows=1 width=12) (actual time=2,593.236..2,744.827 rows=4,717 loops=1)

6. 29.659 2,607.456 ↓ 41,044.0 41,044 1

HashAggregate (cost=51,653.74..51,653.75 rows=1 width=12) (actual time=2,593.208..2,607.456 rows=41,044 loops=1)

7. 308.606 2,577.797 ↓ 41,694.0 41,694 1

Hash Join (cost=41,432.20..51,653.73 rows=1 width=12) (actual time=2,140.518..2,577.797 rows=41,694 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. 3.534 2,162.902 ↓ 1.2 41,044 1

Subquery Scan on max1 (cost=26,808.37..29,257.82 rows=34,622 width=19) (actual time=2,034.028..2,162.902 rows=41,044 loops=1)

9. 35.368 2,159.368 ↓ 1.2 41,044 1

GroupAggregate (cost=26,808.37..28,911.60 rows=34,622 width=19) (actual time=2,034.027..2,159.368 rows=41,044 loops=1)

10. 2,039.229 2,124.000 ↑ 1.0 140,561 1

Sort (cost=26,808.37..27,159.77 rows=140,561 width=19) (actual time=2,034.018..2,124.000 rows=140,561 loops=1)

  • Sort Key: h.cd_prov_ent, h.cd_mun_ent, h.id_habitante
  • Sort Method: external merge Disk: 4672kB
11. 84.771 84.771 ↑ 1.0 140,561 1

Seq Scan on phistorico h (cost=0.00..11,905.82 rows=140,561 width=19) (actual time=0.008..84.771 rows=140,561 loops=1)

  • Filter: ((pos_fecha_real_ult <= '2019-09-02 00:00:00'::timestamp without time zone) AND ((cd_prov_ent)::text = '36'::text) AND ((cd_mun_ent)::text = '008'::text))
12. 39.282 106.289 ↑ 1.0 140,561 1

Hash (cost=10,851.61..10,851.61 rows=140,561 width=27) (actual time=106.289..106.289 rows=140,561 loops=1)

  • Buckets: 2048 Batches: 16 Memory Usage: 552kB
13. 67.007 67.007 ↑ 1.0 140,561 1

Seq Scan on phistorico h1 (cost=0.00..10,851.61 rows=140,561 width=27) (actual time=0.004..67.007 rows=140,561 loops=1)

14. 123.132 123.132 ↓ 0.0 0 41,044

Index Scan using indx_phco_id_prov_mun on phistorico h3 (cost=0.42..8.45 rows=1 width=20) (actual time=0.003..0.003 rows=0 loops=41,044)

  • Index Cond: (id_registro = (max(h1.id_registro)))
  • Filter: ((tipo_mov <> 'B'::bpchar) AND (pos_fecha_nac > '1999-03-09 00:00:00'::timestamp without time zone))
  • Rows Removed by Filter: 1
15. 14.151 14.151 ↑ 1.0 1 4,717

Index Scan using phhojapadronal_pkey on phhojapadronal ph (cost=0.29..0.40 rows=1 width=12) (actual time=0.002..0.003 rows=1 loops=4,717)

  • Index Cond: (id_registro = h3.pos_id_hoja_hist)
16. 4,426.360 7,179.274 ↓ 2,765.0 2,765 4,717

HashAggregate (cost=51,662.55..51,662.56 rows=1 width=4) (actual time=0.586..1.522 rows=2,765 loops=4,717)

  • Filter: (count(*) = 1)
  • Rows Removed by Filter: 7570
17. 16.601 2,752.914 ↓ 26,682.0 26,682 1

Nested Loop (cost=51,654.45..51,662.54 rows=1 width=4) (actual time=2,584.106..2,752.914 rows=26,682 loops=1)

18. 0.000 2,709.631 ↓ 26,682.0 26,682 1

Nested Loop (cost=51,654.16..51,662.21 rows=1 width=8) (actual time=2,584.099..2,709.631 rows=26,682 loops=1)

19. 26.644 2,595.862 ↓ 41,044.0 41,044 1

HashAggregate (cost=51,653.74..51,653.75 rows=1 width=12) (actual time=2,584.076..2,595.862 rows=41,044 loops=1)

20. 307.299 2,569.218 ↓ 41,694.0 41,694 1

Hash Join (cost=41,432.20..51,653.73 rows=1 width=12) (actual time=2,131.525..2,569.218 rows=41,694 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. (...)
21. 3.454 2,156.470 ↓ 1.2 41,044 1

Subquery Scan on max1_1 (cost=26,808.37..29,257.82 rows=34,622 width=19) (actual time=2,025.870..2,156.470 rows=41,044 loops=1)

22. 36.204 2,153.016 ↓ 1.2 41,044 1

GroupAggregate (cost=26,808.37..28,911.60 rows=34,622 width=19) (actual time=2,025.869..2,153.016 rows=41,044 loops=1)

23. 2,033.859 2,116.812 ↑ 1.0 140,561 1

Sort (cost=26,808.37..27,159.77 rows=140,561 width=19) (actual time=2,025.859..2,116.812 rows=140,561 loops=1)

  • Sort Key: h_1.cd_prov_ent, h_1.cd_mun_ent, h_1.id_habitante
  • Sort Method: external merge Disk: 4672kB
24. 82.953 82.953 ↑ 1.0 140,561 1

Seq Scan on phistorico h_1 (cost=0.00..11,905.82 rows=140,561 width=19) (actual time=0.007..82.953 rows=140,561 loops=1)

  • Filter: ((pos_fecha_real_ult <= '2019-09-02 00:00:00'::timestamp without time zone) AND ((cd_prov_ent)::text = '36'::text) AND ((cd_mun_ent)::text = '008'::text))
25. 39.064 105.449 ↑ 1.0 140,561 1

Hash (cost=10,851.61..10,851.61 rows=140,561 width=27) (actual time=105.449..105.449 rows=140,561 loops=1)

  • Buckets: 2048 Batches: 16 Memory Usage: 552kB
26. 66.385 66.385 ↑ 1.0 140,561 1

Seq Scan on phistorico h1_1 (cost=0.00..10,851.61 rows=140,561 width=27) (actual time=0.003..66.385 rows=140,561 loops=1)

27. 123.132 123.132 ↑ 1.0 1 41,044

Index Scan using indx_phco_id_prov_mun on phistorico h3_1 (cost=0.42..8.44 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=41,044)

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

Index Scan using phhojapadronal_pkey on phhojapadronal ph_1 (cost=0.29..0.32 rows=1 width=12) (actual time=0.001..0.001 rows=1 loops=26,682)

  • Index Cond: (id_registro = h3_1.pos_id_hoja_hist)