explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Kcmi

Settings
# exclusive inclusive rows x rows loops node
1. 48.864 35,541.236 ↑ 6.9 18,307 1

Hash Right Join (cost=2,414,699.07..2,418,429.23 rows=127,159 width=379) (actual time=35,471.375..35,541.236 rows=18,307 loops=1)

  • Hash Cond: (prox_cita.cod_pac = p.cod_pac)
2.          

CTE prox_cita

3. 7.415 96.735 ↓ 1.1 37,568 1

Unique (cost=6,261.93..6,447.38 rows=34,759 width=16) (actual time=80.840..96.735 rows=37,568 loops=1)

4. 33.218 89.320 ↓ 1.4 50,217 1

Sort (cost=6,261.93..6,354.66 rows=37,090 width=16) (actual time=80.838..89.320 rows=50,217 loops=1)

  • Sort Key: agenda.cod_pac, agenda.fec_agen
  • Sort Method: quicksort Memory: 3890kB
5. 56.102 56.102 ↓ 1.4 50,217 1

Index Scan using agenda_idx on agenda (cost=0.43..3,447.04 rows=37,090 width=16) (actual time=0.078..56.102 rows=50,217 loops=1)

  • Index Cond: (fec_agen > now())
6.          

CTE ult_cita

7. 684.517 10,908.817 ↓ 3.6 971,774 1

Unique (cost=999,116.03..1,028,443.91 rows=270,177 width=16) (actual time=7,829.787..10,908.817 rows=971,774 loops=1)

8. 7,485.355 10,224.300 ↓ 1.0 5,921,882 1

Sort (cost=999,116.03..1,013,779.97 rows=5,865,577 width=16) (actual time=7,829.786..10,224.300 rows=5,921,882 loops=1)

  • Sort Key: agenda_1.cod_pac, agenda_1.fec_agen DESC
  • Sort Method: external merge Disk: 150432kB
9. 2,738.945 2,738.945 ↓ 1.0 5,921,882 1

Seq Scan on agenda agenda_1 (cost=0.00..239,469.01 rows=5,865,577 width=16) (actual time=0.016..2,738.945 rows=5,921,882 loops=1)

  • Filter: (fec_agen <= now())
  • Rows Removed by Filter: 50217
10. 102.606 102.606 ↓ 1.1 37,568 1

CTE Scan on prox_cita (cost=0.00..695.18 rows=34,759 width=16) (actual time=80.843..102.606 rows=37,568 loops=1)

11. 9.842 35,389.766 ↑ 6.9 18,307 1

Hash (cost=1,378,218.28..1,378,218.28 rows=127,159 width=106) (actual time=35,389.766..35,389.766 rows=18,307 loops=1)

  • Buckets: 131072 Batches: 1 Memory Usage: 3725kB
12. 13.918 35,379.924 ↑ 6.9 18,307 1

Hash Left Join (cost=1,217,555.75..1,378,218.28 rows=127,159 width=106) (actual time=18,183.103..35,379.924 rows=18,307 loops=1)

  • Hash Cond: (d_presu.cod_accion = (serv.cod_serv)::double precision)
13. 13,683.391 35,363.785 ↑ 6.9 18,307 1

Hash Left Join (cost=1,217,388.22..1,376,143.37 rows=127,159 width=103) (actual time=18,180.837..35,363.785 rows=18,307 loops=1)

  • Hash Cond: ((log.folio_presu = d_presu.folio_presu) AND (log.item_presu = d_presu.item_presu))
14. 25.399 12,732.081 ↓ 1.0 18,307 1

Hash Left Join (cost=327,401.97..334,137.47 rows=18,049 width=103) (actual time=9,231.241..12,732.081 rows=18,307 loops=1)

  • Hash Cond: (cp.suc_presu = (c.cod_suc)::double precision)
15. 252.506 12,706.619 ↓ 1.0 18,307 1

Hash Right Join (cost=327,395.89..333,860.66 rows=18,049 width=96) (actual time=9,231.162..12,706.619 rows=18,307 loops=1)

  • Hash Cond: (ult_cita.cod_pac = p.cod_pac)
16. 11,087.149 11,087.149 ↓ 3.6 971,774 1

CTE Scan on ult_cita (cost=0.00..5,403.54 rows=270,177 width=16) (actual time=7,829.791..11,087.149 rows=971,774 loops=1)

17. 10.207 1,366.964 ↓ 1.0 18,307 1

Hash (cost=327,170.28..327,170.28 rows=18,049 width=88) (actual time=1,366.964..1,366.964 rows=18,307 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 2653kB
18. 11.749 1,356.757 ↓ 1.0 18,307 1

Nested Loop Left Join (cost=190,642.76..327,170.28 rows=18,049 width=88) (actual time=1,160.455..1,356.757 rows=18,307 loops=1)

19. 14.087 1,271.780 ↓ 1.0 18,307 1

Nested Loop (cost=190,642.33..317,263.45 rows=18,049 width=54) (actual time=1,160.431..1,271.780 rows=18,307 loops=1)

20. 22.291 1,202.772 ↓ 1.0 18,307 1

Merge Left Join (cost=190,641.90..191,334.03 rows=18,049 width=40) (actual time=1,160.401..1,202.772 rows=18,307 loops=1)

  • Merge Cond: ((log.folio_presu = estado_prestacion.folio_presu) AND (log.item_presu = estado_prestacion.item_trata))
21. 16.091 31.422 ↓ 1.0 18,307 1

Sort (cost=2,893.73..2,938.85 rows=18,049 width=32) (actual time=27.442..31.422 rows=18,307 loops=1)

  • Sort Key: log.folio_presu, log.item_presu
  • Sort Method: quicksort Memory: 2199kB
22. 15.331 15.331 ↓ 1.0 18,307 1

Seq Scan on log_bonificacion log (cost=0.00..1,617.69 rows=18,049 width=32) (actual time=0.015..15.331 rows=18,307 loops=1)

  • Filter: ((fecha >= '2018-10-01 00:00:00-03'::timestamp with time zone) AND (fecha <= '2018-10-31 00:00:00-03'::timestamp with time zone))
  • Rows Removed by Filter: 51006
23. 95.594 1,149.059 ↓ 1.8 130,870 1

Sort (cost=187,748.17..187,932.75 rows=73,829 width=24) (actual time=1,130.618..1,149.059 rows=130,870 loops=1)

  • Sort Key: estado_prestacion.folio_presu, estado_prestacion.item_trata
  • Sort Method: quicksort Memory: 16435kB
24. 17.993 1,053.465 ↓ 1.8 131,720 1

Subquery Scan on estado_prestacion (cost=180,436.98..181,778.40 rows=73,829 width=24) (actual time=990.778..1,053.465 rows=131,720 loops=1)

25. 23.728 1,035.472 ↓ 1.8 131,720 1

Unique (cost=180,436.98..181,040.11 rows=73,829 width=108) (actual time=990.776..1,035.472 rows=131,720 loops=1)

26. 110.665 1,011.744 ↓ 1.6 131,720 1

Sort (cost=180,436.98..180,638.02 rows=80,417 width=108) (actual time=990.775..1,011.744 rows=131,720 loops=1)

  • Sort Key: trata.folio_trata, trata.item_trata DESC
  • Sort Method: quicksort Memory: 16435kB
27. 193.148 901.079 ↓ 1.6 131,720 1

Hash Join (cost=51,028.14..173,884.92 rows=80,417 width=108) (actual time=576.705..901.079 rows=131,720 loops=1)

  • Hash Cond: (trata.folio_trata = cab.folio_trata)
28. 91.095 164.238 ↓ 1.6 131,720 1

Hash Left Join (cost=3,672.23..118,006.28 rows=80,417 width=24) (actual time=30.324..164.238 rows=131,720 loops=1)

  • Hash Cond: (trata.cod_accion = (serv_1.cod_serv)::double precision)
29. 44.506 71.251 ↓ 1.6 131,720 1

Bitmap Heap Scan on deta_tratamiento trata (cost=3,504.71..116,632.50 rows=80,417 width=32) (actual time=28.405..71.251 rows=131,720 loops=1)

  • Recheck Cond: ((cod_sucursal >= '1538362800'::double precision) AND (cod_sucursal <= '1541041199'::double precision))
  • Heap Blocks: exact=9977
30. 26.745 26.745 ↓ 2.7 214,636 1

Bitmap Index Scan on deta_tratamiento_idx_cod_sucursal (cost=0.00..3,484.60 rows=80,417 width=0) (actual time=26.745..26.745 rows=214,636 loops=1)

  • Index Cond: ((cod_sucursal >= '1538362800'::double precision) AND (cod_sucursal <= '1541041199'::double precision))
31. 1.151 1.892 ↓ 1.0 2,694 1

Hash (cost=133.90..133.90 rows=2,690 width=5) (actual time=1.892..1.892 rows=2,694 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 130kB
32. 0.741 0.741 ↓ 1.0 2,694 1

Seq Scan on servicio serv_1 (cost=0.00..133.90 rows=2,690 width=5) (actual time=0.013..0.741 rows=2,694 loops=1)

33. 314.178 543.693 ↑ 1.0 1,324,615 1

Hash (cost=24,314.07..24,314.07 rows=1,325,507 width=16) (actual time=543.693..543.693 rows=1,324,615 loops=1)

  • Buckets: 2097152 Batches: 2 Memory Usage: 47383kB
34. 229.515 229.515 ↑ 1.0 1,324,615 1

Seq Scan on cabe_tratamiento cab (cost=0.00..24,314.07 rows=1,325,507 width=16) (actual time=0.016..229.515 rows=1,324,615 loops=1)

35. 54.921 54.921 ↑ 1.0 1 18,307

Index Scan using cabe_presu_pkey on cabe_presu cp (cost=0.43..6.97 rows=1 width=22) (actual time=0.003..0.003 rows=1 loops=18,307)

  • Index Cond: (folio_presu = log.folio_presu)
36. 73.228 73.228 ↑ 1.0 1 18,307

Index Scan using paciente_pkey on paciente p (cost=0.43..0.54 rows=1 width=40) (actual time=0.003..0.004 rows=1 loops=18,307)

  • Index Cond: ((cp.cod_pac)::double precision = cod_pac)
37. 0.032 0.063 ↓ 1.1 51 1

Hash (cost=5.48..5.48 rows=48 width=20) (actual time=0.063..0.063 rows=51 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
38. 0.031 0.031 ↓ 1.1 51 1

Seq Scan on cliente_sucursal c (cost=0.00..5.48 rows=48 width=20) (actual time=0.012..0.031 rows=51 loops=1)

39. 4,488.024 8,948.313 ↓ 1.1 15,148,699 1

Hash (cost=608,501.70..608,501.70 rows=13,494,370 width=24) (actual time=8,948.313..8,948.313 rows=15,148,699 loops=1)

  • Buckets: 1048576 Batches: 16 Memory Usage: 59980kB
40. 4,460.289 4,460.289 ↓ 1.1 15,148,699 1

Seq Scan on deta_presu d_presu (cost=0.00..608,501.70 rows=13,494,370 width=24) (actual time=0.033..4,460.289 rows=15,148,699 loops=1)

41. 1.280 2.221 ↓ 1.0 2,694 1

Hash (cost=133.90..133.90 rows=2,690 width=11) (actual time=2.221..2.221 rows=2,694 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 145kB
42. 0.941 0.941 ↓ 1.0 2,694 1

Seq Scan on servicio serv (cost=0.00..133.90 rows=2,690 width=11) (actual time=0.012..0.941 rows=2,694 loops=1)