explain.depesz.com

PostgreSQL's explain analyze made readable

Result: fAPi

Settings
# exclusive inclusive rows x rows loops node
1. 0.090 7,160.994 ↓ 10.0 10 1

Sort (cost=1,060,803.95..1,060,803.95 rows=1 width=4,032) (actual time=7,160.993..7,160.994 rows=10 loops=1)

  • Output: final.exme_ctapac_id, final.mrn, final.encounter, final.nombre_pac, final.gender, final.birth_date, final.age_at_admission, final.room, final.bed, final.tipopac, final.physician, final.specialty, final.admission_diagnosis, final.admission_diagnosis_trunk, final.patient_type, final.service_unit, final.dateordered, final.admit_date, final.discharge_date, final.los, final.institucion, final.fecha_prealta, final.prealta, final.destino, final.cargos, final.cargos1, final.subtotal, final.iva, final.cargosfacturados, final.cargosremisiones, final.anticipos, final.anticipos_aplicados, final.pagos, final.cxc, final.pagoscxc, final.saldocxc, final.saldo_con_anticipos, final.saldo
  • Sort Key: final.admit_date DESC
  • Sort Method: quicksort Memory: 30kB
  • Buffers: shared hit=1125692 read=615847 written=386
2.          

CTE params

3. 0.003 0.003 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=64) (actual time=0.003..0.003 rows=1 loops=1)

  • Output: '10001039'::numeric, '10001610'::numeric
4.          

CTE pacientes

5. 0.025 177.048 ↓ 48.0 48 1

Unique (cost=31,119.51..31,119.57 rows=1 width=644) (actual time=176.998..177.048 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, (CASE WHEN (p.sexo = 'F'::bpchar) THEN 'msj.femenino'::text WHEN (p.sexo = 'M'::bpchar) THEN 'msj.masculino'::text WHEN (p.sexo = 'O'::bpchar) THEN 'msj.Other'::text WHEN (p.sexo = 'D'::bpchar) THEN 'unknown'::text ELSE NULL::text END), p.fechanac, (CASE WHEN (date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE CASE WHEN (date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE date_part('day'::text, age(now(), (p.fechanac)::timestamp with time zone)) END END), h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, ("substring"((cp.diagnostico_ingreso)::text, 0, 50)), tp.name, su.name, cp.dateordered, cp.dateordered, (COALESCE(cp.fechaalta, cp.fechacierre)), (CASE WHEN (cp.encounterstatus = 'A'::bpchar) THEN 0 WHEN (COALESCE(cp.fechaalta, cp.fechacierre) IS NULL) THEN CASE WHEN ((to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END ELSE CASE WHEN ((to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END END), (first_value(bp.name) OVER (?)), cp.fechaprealta, (CASE WHEN (cp.fechaprealta IS NULL) THEN 'imag.notChecked'::text ELSE 'imag.checked'::text END), ds.name, pa.priority, pa.exme_paciente_id
  • Buffers: shared hit=763 read=19656
6.          

Initplan (forUnique)

7. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params (cost=0.00..0.02 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=1)

  • Output: params.org_id
8. 0.009 0.009 ↑ 1.0 1 1

CTE Scan on params params_1 (cost=0.00..0.02 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=1)

  • Output: params_1.org_id
9. 0.008 0.008 ↑ 1.0 1 1

CTE Scan on params params_2 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.008 rows=1 loops=1)

  • Output: params_2.org_id
10. 0.124 177.002 ↓ 48.0 48 1

Sort (cost=31,119.45..31,119.46 rows=1 width=644) (actual time=176.997..177.002 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, (CASE WHEN (p.sexo = 'F'::bpchar) THEN 'msj.femenino'::text WHEN (p.sexo = 'M'::bpchar) THEN 'msj.masculino'::text WHEN (p.sexo = 'O'::bpchar) THEN 'msj.Other'::text WHEN (p.sexo = 'D'::bpchar) THEN 'unknown'::text ELSE NULL::text END), p.fechanac, (CASE WHEN (date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE CASE WHEN (date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE date_part('day'::text, age(now(), (p.fechanac)::timestamp with time zone)) END END), h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, ("substring"((cp.diagnostico_ingreso)::text, 0, 50)), tp.name, su.name, cp.dateordered, cp.dateordered, (COALESCE(cp.fechaalta, cp.fechacierre)), (CASE WHEN (cp.encounterstatus = 'A'::bpchar) THEN 0 WHEN (COALESCE(cp.fechaalta, cp.fechacierre) IS NULL) THEN CASE WHEN ((to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END ELSE CASE WHEN ((to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END END), (first_value(bp.name) OVER (?)), cp.fechaprealta, (CASE WHEN (cp.fechaprealta IS NULL) THEN 'imag.notChecked'::text ELSE 'imag.checked'::text END), ds.name, pa.priority, pa.exme_paciente_id
  • Sort Key: cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, (CASE WHEN (p.sexo = 'F'::bpchar) THEN 'msj.femenino'::text WHEN (p.sexo = 'M'::bpchar) THEN 'msj.masculino'::text WHEN (p.sexo = 'O'::bpchar) THEN 'msj.Other'::text WHEN (p.sexo = 'D'::bpchar) THEN 'unknown'::text ELSE NULL::text END), p.fechanac, (CASE WHEN (date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE CASE WHEN (date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE date_part('day'::text, age(now(), (p.fechanac)::timestamp with time zone)) END END), h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, ("substring"((cp.diagnostico_ingreso)::text, 0, 50)), tp.name, su.name, cp.dateordered, (COALESCE(cp.fechaalta, cp.fechacierre)), (CASE WHEN (cp.encounterstatus = 'A'::bpchar) THEN 0 WHEN (COALESCE(cp.fechaalta, cp.fechacierre) IS NULL) THEN CASE WHEN ((to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END ELSE CASE WHEN ((to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END END), (first_value(bp.name) OVER (?)), cp.fechaprealta, (CASE WHEN (cp.fechaprealta IS NULL) THEN 'imag.notChecked'::text ELSE 'imag.checked'::text END), ds.name
  • Sort Method: quicksort Memory: 41kB
  • Buffers: shared hit=763 read=19656
11. 0.581 176.878 ↓ 48.0 48 1

WindowAgg (cost=31,119.29..31,119.44 rows=1 width=644) (actual time=176.370..176.878 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, CASE WHEN (p.sexo = 'F'::bpchar) THEN 'msj.femenino'::text WHEN (p.sexo = 'M'::bpchar) THEN 'msj.masculino'::text WHEN (p.sexo = 'O'::bpchar) THEN 'msj.Other'::text WHEN (p.sexo = 'D'::bpchar) THEN 'unknown'::text ELSE NULL::text END, p.fechanac, CASE WHEN (date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('year'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE CASE WHEN (date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) > '0'::double precision) THEN date_part('month'::text, age(now(), (p.fechanac)::timestamp with time zone)) ELSE date_part('day'::text, age(now(), (p.fechanac)::timestamp with time zone)) END END, h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, "substring"((cp.diagnostico_ingreso)::text, 0, 50), tp.name, su.name, cp.dateordered, cp.dateordered, COALESCE(cp.fechaalta, cp.fechacierre), CASE WHEN (cp.encounterstatus = 'A'::bpchar) THEN 0 WHEN (COALESCE(cp.fechaalta, cp.fechacierre) IS NULL) THEN CASE WHEN ((to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(now(), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END ELSE CASE WHEN ((to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) = 0) THEN 1 ELSE (to_date(to_char(COALESCE(cp.fechaalta, cp.fechacierre), 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text) - to_date(to_char(cp.dateordered, 'dd/mm/yyyy'::text), 'dd/mm/yyyy'::text)) END END, first_value(bp.name) OVER (?), cp.fechaprealta, CASE WHEN (cp.fechaprealta IS NULL) THEN 'imag.notChecked'::text ELSE 'imag.checked'::text END, ds.name, pa.priority, pa.exme_paciente_id
  • Buffers: shared hit=763 read=19656
12. 0.202 176.297 ↓ 48.0 48 1

Sort (cost=31,119.29..31,119.29 rows=1 width=538) (actual time=176.293..176.297 rows=48 loops=1)

  • Output: pa.priority, pa.exme_paciente_id, cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, p.sexo, p.fechanac, h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, tp.name, su.name, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, bp.name, cp.fechaprealta, ds.name
  • Sort Key: pa.exme_paciente_id, pa.priority
  • Sort Method: quicksort Memory: 39kB
  • Buffers: shared hit=763 read=19656
13. 0.096 176.095 ↓ 48.0 48 1

Nested Loop Left Join (cost=251.15..31,119.28 rows=1 width=538) (actual time=41.171..176.095 rows=48 loops=1)

  • Output: pa.priority, pa.exme_paciente_id, cp.exme_ctapac_id, mrn.documentno, cp.documentno, p.nombre_pac, p.sexo, p.fechanac, h.name, c.name, cp.exme_tipopaciente_id, m.nombre_med, me.name, cp.diagnostico_ingreso, tp.name, su.name, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, bp.name, cp.fechaprealta, ds.name
  • Inner Unique: true
  • Join Filter: ((bp.ad_client_id = '0'::numeric) OR (bp.ad_client_id = cp.ad_client_id))
  • Buffers: shared hit=763 read=19656
14. 0.101 175.807 ↓ 48.0 48 1

Nested Loop Left Join (cost=250.87..31,118.90 rows=1 width=522) (actual time=41.157..175.807 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, mrn.documentno, me.name, m.nombre_med, su.name, tp.name, c.name, h.name, pa.priority, pa.exme_paciente_id, pa.c_bpartner_id, ds.name
  • Inner Unique: true
  • Join Filter: (pa.isactive = 'Y'::bpchar)
  • Buffers: shared hit=748 read=19644
15. 0.091 175.706 ↓ 48.0 48 1

Nested Loop Left Join (cost=250.73..31,118.36 rows=1 width=271) (actual time=41.145..175.706 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, mrn.documentno, me.name, m.nombre_med, su.name, tp.name, c.name, h.name, pa.priority, pa.exme_paciente_id, pa.isactive, pa.c_bpartner_id
  • Buffers: shared hit=748 read=19644
16. 0.079 175.039 ↓ 48.0 48 1

Nested Loop Left Join (cost=250.31..31,117.90 rows=1 width=257) (actual time=41.117..175.039 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name, m.nombre_med, su.name, tp.name, c.name, h.name
  • Inner Unique: true
  • Buffers: shared hit=639 read=19600
17. 0.076 174.864 ↓ 48.0 48 1

Nested Loop Left Join (cost=250.03..31,117.53 rows=1 width=255) (actual time=41.103..174.864 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name, m.nombre_med, su.name, tp.name, c.name, c.exme_habitacion_id
  • Inner Unique: true
  • Buffers: shared hit=616 read=19593
18. 0.109 174.692 ↓ 48.0 48 1

Nested Loop Left Join (cost=249.76..31,113.95 rows=1 width=248) (actual time=41.091..174.692 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name, m.nombre_med, su.name, tp.name
  • Inner Unique: true
  • Buffers: shared hit=592 read=19587
19. 0.111 174.535 ↓ 48.0 48 1

Nested Loop (cost=249.48..31,110.87 rows=1 width=238) (actual time=41.078..174.535 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name, m.nombre_med, su.name
  • Inner Unique: true
  • Buffers: shared hit=565 read=19584
20. 0.113 174.184 ↓ 48.0 48 1

Nested Loop (cost=249.20..31,105.84 rows=1 width=231) (actual time=41.039..174.184 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_estserv_id, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name, m.nombre_med
  • Inner Unique: true
  • Buffers: shared hit=426 read=19579
21. 0.123 173.495 ↓ 48.0 48 1

Nested Loop (cost=248.91..31,098.99 rows=1 width=211) (actual time=41.000..173.495 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_medico_id, cp.exme_estserv_id, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno, me.name
  • Inner Unique: true
  • Buffers: shared hit=328 read=19533
22. 0.140 173.132 ↓ 48.0 48 1

Nested Loop (cost=248.64..31,095.17 rows=1 width=186) (actual time=40.966..173.132 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_especialidad_id, cp.exme_medico_id, cp.exme_estserv_id, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, p.nombre_pac, p.sexo, p.fechanac, p.exme_paciente_id, mrn.documentno
  • Inner Unique: true
  • Join Filter: (cp.exme_paciente_id = p.exme_paciente_id)
  • Buffers: shared hit=188 read=19529
23. 0.171 172.032 ↓ 48.0 48 1

Nested Loop (cost=248.21..31,088.42 rows=1 width=136) (actual time=40.920..172.032 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.documentno, cp.exme_tipopaciente_id, cp.diagnostico_ingreso, cp.dateordered, cp.fechaalta, cp.fechacierre, cp.encounterstatus, cp.fechaprealta, cp.exme_paciente_id, cp.exme_especialidad_id, cp.exme_medico_id, cp.exme_estserv_id, cp.exme_cama_id, cp.exme_dischargestatus_id, cp.ad_client_id, mrn.documentno, mrn.exme_paciente_id
  • Buffers: shared hit=99 read=19426
24. 162.442 170.661 ↓ 1.5 48 1

Bitmap Heap Scan on public.exme_ctapac cp (cost=247.79..30,809.40 rows=33 width=129) (actual time=40.848..170.661 rows=48 loops=1)

  • Output: cp.exme_ctapac_id, cp.ad_client_id, cp.ad_org_id, cp.isactive, cp.created, cp.createdby, cp.updated, cp.updatedby, cp.documentno, cp.docstatus, cp.docaction, cp.processing, cp.processed, cp.c_doctype_id, cp.c_doctypetarget_id, cp.description, cp.isapproved, cp.iscreditapproved, cp.isinvoiced, cp.isprinted, cp.dateordered, cp.dateprinted, cp.dateacct, cp.priorityrule, cp.grandtotal, cp.m_pricelist_id, cp.c_campaign_id, cp.c_project_id, cp.c_activity_id, cp.ad_user_id, cp.ad_orgtrx_id, cp.user1_id, cp.user2_id, cp.fechacancel, cp.exme_paciente_id, cp.exme_especialidad_id, cp.exme_motivocita_id, cp.estatus, cp.exme_medico_id, cp.ref_ctapac_id, cp.c_currency_id, cp.ad_printformat_id, cp.impcontrato, cp.impconsent, cp.impdatos, cp.impbrazalete, cp.exme_diagnostico_id, cp.exme_cama_id, cp.tipoarea, cp.fechacargodiario, cp.fechacierre, cp.exme_paqbase_version_id, cp.exme_ctapacext_id, cp.exme_estserv_id, cp.isuso, cp.isbloqueada, cp.isautorizada, cp.diagnostico_ingreso, cp.fechaalta, cp.actualizadoalta, cp.statusalta, cp.exme_camaing_id, cp.fechaprealta, cp.actualizadoprealta, cp.isfactespec, cp.ref_ctapacfam_id, cp.exme_descpreciofijo_id, cp.tiposangre, cp.exme_tipotrasplante_id, cp.exme_motivoegreso_id, cp.casosmedicos, cp.exme_estserving_id, cp.fechatraslado, cp.exme_procedencia_id, cp.isgenerated, cp.statuseleg, cp.instruccionalta, cp.nombrearchivo, cp.formatoarchivo, cp.archivo, cp.informealta, cp.exme_medico2_id, cp.exme_especialidad2_id, cp.exme_dischargestatus_id, cp.resstatus, cp.billingstatus, cp.exme_tipoprod_id, cp.drg, cp.exme_tipopaciente_id, cp.exme_arrivalmode_id, cp.exme_admittype_id, cp.exme_admitsource_id, cp.isnewborn, cp.exme_beneficiosh_id, cp.exme_estservprov_id, cp.billdate, cp.exme_area_id, cp.ref_unit_id, cp.encounterstatus, cp.exme_medicorefer_id, cp.exme_especialidadrefer_id, cp.exme_ctapacrefer_id, cp.isidentifier, cp.email, cp.requester, cp.fechaenv, cp.departuredate, cp.exme_pos_id, cp.exme_drg_id, cp.noinsurancecoverage, cp.nostatementage, cp.validonqueue, cp.exme_accompaniedby_id, cp.exme_transport_mode_id, cp.exme_discharged_via_id, cp.comments, cp.exme_institucion_id, cp.billingtype, cp.coded, cp.codingdate, cp.codedprof, cp.codingdateprof, cp.institutionalstatus, cp.institutionalstep, cp.isvalid, cp.nombre_pac, cp.mrn, cp.processingpaq, cp.processingpaq2, cp.isclosed, cp.exme_eventmerge_id, cp.fallrisk, cp.triage, cp.apollo_policy, cp.apollo_claim
  • Recheck Cond: (cp.ad_org_id = $2)
  • Filter: ((COALESCE(cp.fechaalta, cp.fechacierre) IS NULL) AND (cp.fechacancel IS NULL) AND (cp.isactive = 'Y'::bpchar) AND ((cp.tipoarea)::text = ANY ('{A,H,O,U}'::text[])) AND CASE WHEN ($3 = '10001437'::numeric) THEN (cp.exme_ctapac_id <> ALL ('{10084687,10146732,10232143,10234525,10235214,10084414,10229307}'::numeric[])) ELSE true END)
  • Rows Removed by Filter: 26064
  • Heap Blocks: exact=19258
  • Buffers: shared hit=4 read=19328
25. 8.219 8.219 ↓ 2.0 26,112 1

Bitmap Index Scan on ender_exme_ctapac_active_client_org (cost=0.00..247.78 rows=13,247 width=0) (actual time=8.219..8.219 rows=26,112 loops=1)

  • Index Cond: (cp.ad_org_id = $2)
  • Buffers: shared read=74
26. 1.200 1.200 ↑ 1.0 1 48

Index Scan using exme_histexp_pacact_idx on public.exme_hist_exp mrn (cost=0.42..8.45 rows=1 width=21) (actual time=0.024..0.025 rows=1 loops=48)

  • Output: mrn.exme_hist_exp_id, mrn.ad_client_id, mrn.ad_org_id, mrn.isactive, mrn.created, mrn.createdby, mrn.updated, mrn.updatedby, mrn.exme_paciente_id, mrn.cancelado, mrn.fecha_exp, mrn.nombre_pac, mrn.isprestado, mrn.value, mrn.estatus, mrn.expediente, mrn.documentno, mrn.c_doctype_id
  • Index Cond: (mrn.exme_paciente_id = cp.exme_paciente_id)
  • Filter: (mrn.ad_org_id = $2)
  • Rows Removed by Filter: 0
  • Buffers: shared hit=95 read=98
27. 0.960 0.960 ↑ 1.0 1 48

Index Scan using exme_paciente_pkey on public.exme_paciente p (cost=0.42..6.74 rows=1 width=62) (actual time=0.020..0.020 rows=1 loops=48)

  • Output: p.exme_paciente_id, p.ad_client_id, p.ad_org_id, p.isactive, p.created, p.createdby, p.updated, p.updatedby, p.value, p.name, p.description, p.nombre2, p.apellido1, p.apellido2, p.apellido3, p.sexo, p.imss, p.rfc, p.curp, p.edocivil, p.fechanac, p.horanac, p.c_location_id, p.exme_patientclass_id, p.exme_religion_id, p.esasegurado, p.limitecredito, p.telparticular, p.email, p.nombrefamiliar, p.dirfamiliar, p.telfamiliar, p.poliza, p.titular, p.noautorizacion, p.c_bpartner_id, p.observaciones, p.c_bpartner_seg_id, p.c_location_nac_id, p.exme_parentesco_id, p.c_bpartner_location_id, p.fechabaja, p.fechavigencia, p.derechohabiente, p.estitular, p.derechohabienteotro, p.poblacionabierta, p.particular, p.titular_id, p.exme_archclinico_id, p.nosiniestro, p.nombre_fam, p.apellido1_fam, p.apellido2_fam, p.telparticular_fam, p.antiguedad_fam, p.puesto_fam, p.rfc_resp, p.exme_ocupacion_fam_id, p.dirpersresp, p.dirtrabpersresp, p.limcredderechoh, p.imagen, p.nombre_pac, p.exme_nacionalidad_id, p.exme_escolaridad_id, p.exme_ocupacion_id, p.exme_institucion_id, p.exme_institucion_names, p.exme_otra_inst, p.exme_especialidad_ts_id, p.exme_referencia_id, p.exme_referencia_int_id, p.exme_diagnostico_ingreso_descr, p.exme_diagnostico_egreso_descr, p.exme_expediente_id, p.c_country_nac_id, p.c_region_nac_id, p.exme_delegacion_paciente_id, p.exme_delegacion_nacimiento_id, p.fechavencimiento, p.documentoconvenio, p.nomina, p.nofamiliar, p.empresa_lab_pac, p.puesto_lab_pac, p.direccion_lab_pac, p.telefono_lab_pac1, p.telefono_lab_pac2, p.telefono_lab_pac3, p.coloniapersresp, p.ciudadpersresp, p.cppersresp, p.c_region_persresp_id, p.c_country_persresp_id, p.seguropopular, p.isfactespec, p.verificado, p.ispension, p.exme_rfc_id, p.isdonador, p.isreceptor, p.c_locationfam_id, p.c_locationperresp_id, p.rfc_fam, p.isprinted, p.ischangelog, p.exme_refer_id, p.isrefer, p.fecharegistro, p.c_locationreg_id, p.exme_arma_id, p.exme_grado_id, p.exme_grupo_especialidad_id, p.exme_unidad_id, p.expediente, p.fechaini, p.fechaini_seg, p.fechafin_seg, p.ad_user_id, p.exme_lenguanativa_id, p.exme_gpoetnico_id, p.exme_razas_id, p.copykin, p.copyresponsible, p.sendinformation, p.telcelular, p.teltrabajo, p.exme_pacientefam_id, p.exme_parentescofam_id, p.peso, p.talla, p.c_bpartnerpac_id, p.c_location_mail_id, p.createbeneficiary, p.eligibilityapplication, p.exme_medico_id, p.copylocation, p.drugeligibilityapplication, p.particularcomcode, p.familiarcomcode, p.work1comcode, p.work2comcode, p.work3comcode, p.fecha_muerte, p.createreport, p.exme_suffix_id, p.c_regiondriverlic_id, p.exme_employment_id, p.copymail, p.tiposangre, p.supportemail, p.mrn, p.title, p.isnss, p.suffixnss, p.ad_org_elig_id, p.ad_language, p.noalergiasmed, p.estatura, p.diagconocido, p.prescactivas, p.password, p.orientation, p.gender
  • Index Cond: (p.exme_paciente_id = mrn.exme_paciente_id)
  • Buffers: shared hit=89 read=103
28. 0.240 0.240 ↑ 1.0 1 48

Index Scan using exme_especialidad_pkey on public.exme_especialidad me (cost=0.28..3.81 rows=1 width=37) (actual time=0.005..0.005 rows=1 loops=48)

  • Output: me.exme_especialidad_id, me.ad_client_id, me.ad_org_id, me.isactive, me.created, me.createdby, me.updated, me.updatedby, me.value, me.name, me.description, me.pricelist, me.intervaloconsulta, me.ad_color_id, me.tiempoespera, me.ref_exme_especialidad_id, me.ismed, me.spectype, me.isenf, me.isdefault
  • Index Cond: (me.exme_especialidad_id = cp.exme_especialidad_id)
  • Buffers: shared hit=140 read=4
29. 0.576 0.576 ↑ 1.0 1 48

Index Scan using exme_medico_pkey on public.exme_medico m (cost=0.29..6.85 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=48)

  • Output: m.exme_medico_id, m.ad_client_id, m.ad_org_id, m.isactive, m.created, m.createdby, m.updated, m.updatedby, m.value, m.name, m.description, m.apellido1, m.apellido2, m.sexo, m.estasuspendido, m.fechanac, m.celular, m.email, m.esinterno, m.exme_tipomedico_id, m.rfc, m.curp, m.edocivil, m.c_location_id, m.telparticular, m.radio, m.fechaingreso, m.cedprofesional, m.codsanidad, m.fechabaja, m.exme_motivobaja_id, m.fechatitulo, m.exme_universidad_id, m.fechacertifconsejo, m.fechavencimcertif, m.estarecertificado, m.tieneincentivo, m.mensajemedico, m.c_location_cons_id, m.telconsultorio, m.exme_centromedico_id, m.noconsultorio, m.exme_turnos_id, m.intervaloconsulta, m.ad_user_id, m.m_product_id, m.estacertifconsejo, m.modificaenfactura, m.nombre_med, m.c_location_fam_id, m.exme_medico_sust_id, m.scalemin, m.itemclass, m.tiempoespera, m.maxcitas, m.deanumber, m.contact, m.faxnumber, m.statelicensenumber, m.exme_amaspecialty_id, m.servicelevel, m.phoneext, m.medicaidno, m.medicareno
  • Index Cond: (m.exme_medico_id = cp.exme_medico_id)
  • Buffers: shared hit=98 read=46
30. 0.240 0.240 ↑ 1.0 1 48

Index Scan using exme_estserv_pkey on public.exme_estserv su (cost=0.28..5.02 rows=1 width=21) (actual time=0.005..0.005 rows=1 loops=48)

  • Output: su.exme_estserv_id, su.ad_client_id, su.ad_org_id, su.isactive, su.created, su.createdby, su.updated, su.updatedby, su.value, su.name, su.description, su.exme_area_id, su.ad_orgtrx_id, su.tipoarea, su.usalpcecofi, su.isbancoojos, su.piso, su.manejaagenda, su.isdefault, su.operatingroom, su.isexternal
  • Index Cond: (su.exme_estserv_id = cp.exme_estserv_id)
  • Buffers: shared hit=139 read=5
31. 0.048 0.048 ↓ 0.0 0 48

Index Scan using exme_tipopaciente_pkey on public.exme_tipopaciente tp (cost=0.28..3.08 rows=1 width=17) (actual time=0.001..0.001 rows=0 loops=48)

  • Output: tp.exme_tipopaciente_id, tp.ad_client_id, tp.ad_org_id, tp.isactive, tp.created, tp.createdby, tp.updated, tp.updatedby, tp.value, tp.name, tp.description, tp.tipoarea, tp.exme_typeofbill_id, tp.exme_pos_id, tp.exme_admittype_id, tp.ad_orgtrx_id, tp.value_hl7
  • Index Cond: (tp.exme_tipopaciente_id = cp.exme_tipopaciente_id)
  • Buffers: shared hit=27 read=3
32. 0.096 0.096 ↓ 0.0 0 48

Index Scan using exme_cama_pkey on public.exme_cama c (cost=0.28..3.57 rows=1 width=21) (actual time=0.002..0.002 rows=0 loops=48)

  • Output: c.exme_cama_id, c.ad_client_id, c.ad_org_id, c.exme_habitacion_id, c.isactive, c.created, c.createdby, c.updated, c.updatedby, c.value, c.name, c.description, c.estatus, c.exme_ctapac_id, c.iscensable, c.cama_alterna
  • Index Cond: (c.exme_cama_id = cp.exme_cama_id)
  • Buffers: shared hit=24 read=6
33. 0.096 0.096 ↓ 0.0 0 48

Index Scan using exme_habitacion_pkey on public.exme_habitacion h (cost=0.28..0.37 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=48)

  • Output: h.exme_habitacion_id, h.ad_client_id, h.ad_org_id, h.isactive, h.created, h.createdby, h.updated, h.updatedby, h.value, h.name, h.description, h.exme_tipohabitacion_id, h.exme_area_id, h.exme_especialidad_id, h.exme_cdiario_id, h.estatus, h.exme_estserv_id, h.exme_estservalm_id, h.tipoarea, h.tipolimpieza
  • Index Cond: (h.exme_habitacion_id = c.exme_habitacion_id)
  • Buffers: shared hit=23 read=7
34. 0.576 0.576 ↓ 0.0 0 48

Index Scan using exme_pacienteaseg_exme_paciente_id on public.exme_pacienteaseg pa (cost=0.42..0.46 rows=1 width=20) (actual time=0.012..0.012 rows=0 loops=48)

  • Output: pa.exme_pacienteaseg_id, pa.ad_client_id, pa.ad_org_id, pa.isactive, pa.created, pa.createdby, pa.updated, pa.updatedby, pa.c_bpartner_id, pa.exme_paciente_id, pa.ismain, pa.poliza, pa.grupo, pa.fechaini, pa.fechafin, pa.exme_planaseg_id, pa.namepac, pa.fechanac, pa.priority, pa.fecha, pa.exme_paciente1_id, pa.exme_paciente2_id, pa.exme_parentesco_id, pa.name, pa.c_location_id, pa.driverlicense, pa.c_regiondriverlic_id, pa.phone, pa.celular, pa.particularcomcode, pa.exme_employment_id, pa.type, pa.rfc, pa.exme_parentesco2_id, pa.type2, pa.ispolicyholder, pa.copylocation, pa.c_locationphys_id, pa.telefonotrabajo, pa.last_name, pa.sex, pa.supportbilling, pa.insurancename, pa.c_locationinsurance_id, pa.insurancetaxid, pa.exme_ctapac_id, pa.company, pa.emprelationship, pa.apollo_policy
  • Index Cond: (pa.exme_paciente_id = p.exme_paciente_id)
  • Buffers: shared hit=109 read=44
35. 0.000 0.000 ↓ 0.0 0 48

Index Scan using exme_dischargestatus_pkey on public.exme_dischargestatus ds (cost=0.14..0.52 rows=1 width=274) (actual time=0.000..0.000 rows=0 loops=48)

  • Output: ds.exme_dischargestatus_id, ds.ad_client_id, ds.ad_org_id, ds.isactive, ds.created, ds.createdby, ds.updated, ds.updatedby, ds.value, ds.name, ds.description, ds.isexclude, ds.type
  • Index Cond: (ds.exme_dischargestatus_id = cp.exme_dischargestatus_id)
36. 0.192 0.192 ↓ 0.0 0 48

Index Scan using c_bpartner_pkey on public.c_bpartner bp (cost=0.29..0.37 rows=1 width=42) (actual time=0.004..0.004 rows=0 loops=48)

  • Output: bp.c_bpartner_id, bp.ad_client_id, bp.ad_org_id, bp.isactive, bp.created, bp.createdby, bp.updated, bp.updatedby, bp.value, bp.name, bp.name2, bp.description, bp.issummary, bp.c_bp_group_id, bp.isonetime, bp.isprospect, bp.isvendor, bp.iscustomer, bp.isemployee, bp.issalesrep, bp.referenceno, bp.duns, bp.url, bp.ad_language, bp.taxid, bp.istaxexempt, bp.c_invoiceschedule_id, bp.rating, bp.salesvolume, bp.numberemployees, bp.naics, bp.firstsale, bp.acqusitioncost, bp.potentiallifetimevalue, bp.actuallifetimevalue, bp.shareofcustomer, bp.paymentrule, bp.so_creditlimit, bp.so_creditused, bp.c_paymentterm_id, bp.m_pricelist_id, bp.m_discountschema_id, bp.c_dunning_id, bp.isdiscountprinted, bp.so_description, bp.poreference, bp.paymentrulepo, bp.po_pricelist_id, bp.po_discountschema_id, bp.po_paymentterm_id, bp.documentcopies, bp.c_greeting_id, bp.invoicerule, bp.deliveryrule, bp.freightcostrule, bp.deliveryviarule, bp.salesrep_id, bp.sendemail, bp.bpartner_parent_id, bp.invoice_printformat_id, bp.socreditstatus, bp.shelflifeminpct, bp.ad_orgbp_id, bp.flatdiscount, bp.totalopenbalance, bp.modificaenfactura, bp.isminipack, bp.isbanorte, bp.isgi, bp.isfactespec, bp.isnotacargo, bp.facturaraseg, bp.identificador, bp.ispension, bp.referencia_cliente, bp.referencia_direccion, bp.imprimefactura, bp.email, bp.facturaemail, bp.copias, bp.impresiones, bp.rfc, bp.llavedebusqueda, bp.impresionde, bp.enviaemail, bp.tipoproveedor, bp.isexento, bp.ispotaxexempt, bp.logo_id, bp.c_taxgroup_id, bp.dunninggrace, bp.requerireleg, bp.ispatient, bp.elig_id_send, bp.elig_id_recp, bp.claim_id_send, bp.claim_id_recp, bp.isdefault, bp.useclearinghouse, bp.exme_financialclass_id, bp.exme_payerclass_id, bp.bp_class, bp.queuingtime, bp.supporteclaim, bp.supportelegibilityverification, bp.supportbilling, bp.isorderfaclinecategory, bp.reward_card, bp.reward_amount, bp.isnational, bp.iscreditor, bp.ftpserver, bp.sendstatment, bp.code, bp.ftpuser, bp.ftppassword, bp.ftpdir, bp.sendstatementauto, bp.consolidated, bp.exme_localidad_name, bp.invoiceuomtype, bp.provider, bp.showpartnerdata, bp.hospicheck, bp.withhold, bp.c_chargecreditor_id, bp.c_chargeemployee_id, bp.exme_taxregimecode_id, bp.exme_persontype_id, bp.exme_vattax_id
  • Index Cond: (bp.c_bpartner_id = pa.c_bpartner_id)
  • Filter: (bp.ad_org_id = ANY (ARRAY['0'::numeric, $1]))
  • Buffers: shared hit=15 read=12
37.          

CTE cargos0

38. 0.939 66.177 ↑ 1.1 10 1

HashAggregate (cost=32,619.76..32,619.90 rows=11 width=48) (actual time=66.167..66.177 rows=10 loops=1)

  • Output: c0.exme_ctapac_id, ((sum(c0.linenetamt) OVER (?) + sum(c0.taxamt) OVER (?)))
  • Group Key: c0.exme_ctapac_id, (sum(c0.linenetamt) OVER (?) + sum(c0.taxamt) OVER (?))
  • Buffers: shared hit=26567
39.          

CTE c0

40. 0.630 62.428 ↓ 140.8 1,549 1

Unique (cost=32,618.91..32,619.05 rows=11 width=76) (actual time=61.674..62.428 rows=1,549 loops=1)

  • Output: cpd.exme_ctapac_id, cpd.exme_ctapacdet_id, (COALESCE(cpd.linenetamt, '0'::numeric)), (COALESCE(cpd.taxamt, '0'::numeric))
  • Buffers: shared hit=26567
41.          

Initplan (forUnique)

42. 0.013 0.013 ↑ 1.0 1 1

CTE Scan on params params_3 (cost=0.00..0.02 rows=1 width=32) (actual time=0.013..0.013 rows=1 loops=1)

  • Output: params_3.org_id
43. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on params params_4 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: params_4.org_id
44. 3.841 61.779 ↓ 140.8 1,549 1

Sort (cost=32,618.87..32,618.90 rows=11 width=76) (actual time=61.660..61.779 rows=1,549 loops=1)

  • Output: cpd.exme_ctapac_id, cpd.exme_ctapacdet_id, (COALESCE(cpd.linenetamt, '0'::numeric)), (COALESCE(cpd.taxamt, '0'::numeric))
  • Sort Key: cpd.exme_ctapac_id, cpd.exme_ctapacdet_id, (COALESCE(cpd.linenetamt, '0'::numeric)), (COALESCE(cpd.taxamt, '0'::numeric))
  • Sort Method: quicksort Memory: 170kB
  • Buffers: shared hit=26567
45. 0.693 57.938 ↓ 140.8 1,549 1

Nested Loop (cost=248.78..32,618.68 rows=11 width=76) (actual time=47.155..57.938 rows=1,549 loops=1)

  • Output: cpd.exme_ctapac_id, cpd.exme_ctapacdet_id, COALESCE(cpd.linenetamt, '0'::numeric), COALESCE(cpd.taxamt, '0'::numeric)
  • Inner Unique: true
  • Buffers: shared hit=26567
46. 0.422 51.017 ↓ 81.9 1,557 1

Nested Loop (cost=248.35..32,589.95 rows=19 width=30) (actual time=23.286..51.017 rows=1,557 loops=1)

  • Output: cpd.exme_ctapac_id, cpd.exme_ctapacdet_id, cpd.linenetamt, cpd.taxamt, cpd.exme_ctapacext_id
  • Buffers: shared hit=20339
47. 40.913 47.187 ↑ 1.4 48 1

Bitmap Heap Scan on public.exme_ctapac cp_1 (cost=247.79..30,660.38 rows=66 width=6) (actual time=16.513..47.187 rows=48 loops=1)

  • Output: cp_1.exme_ctapac_id, cp_1.ad_client_id, cp_1.ad_org_id, cp_1.isactive, cp_1.created, cp_1.createdby, cp_1.updated, cp_1.updatedby, cp_1.documentno, cp_1.docstatus, cp_1.docaction, cp_1.processing, cp_1.processed, cp_1.c_doctype_id, cp_1.c_doctypetarget_id, cp_1.description, cp_1.isapproved, cp_1.iscreditapproved, cp_1.isinvoiced, cp_1.isprinted, cp_1.dateordered, cp_1.dateprinted, cp_1.dateacct, cp_1.priorityrule, cp_1.grandtotal, cp_1.m_pricelist_id, cp_1.c_campaign_id, cp_1.c_project_id, cp_1.c_activity_id, cp_1.ad_user_id, cp_1.ad_orgtrx_id, cp_1.user1_id, cp_1.user2_id, cp_1.fechacancel, cp_1.exme_paciente_id, cp_1.exme_especialidad_id, cp_1.exme_motivocita_id, cp_1.estatus, cp_1.exme_medico_id, cp_1.ref_ctapac_id, cp_1.c_currency_id, cp_1.ad_printformat_id, cp_1.impcontrato, cp_1.impconsent, cp_1.impdatos, cp_1.impbrazalete, cp_1.exme_diagnostico_id, cp_1.exme_cama_id, cp_1.tipoarea, cp_1.fechacargodiario, cp_1.fechacierre, cp_1.exme_paqbase_version_id, cp_1.exme_ctapacext_id, cp_1.exme_estserv_id, cp_1.isuso, cp_1.isbloqueada, cp_1.isautorizada, cp_1.diagnostico_ingreso, cp_1.fechaalta, cp_1.actualizadoalta, cp_1.statusalta, cp_1.exme_camaing_id, cp_1.fechaprealta, cp_1.actualizadoprealta, cp_1.isfactespec, cp_1.ref_ctapacfam_id, cp_1.exme_descpreciofijo_id, cp_1.tiposangre, cp_1.exme_tipotrasplante_id, cp_1.exme_motivoegreso_id, cp_1.casosmedicos, cp_1.exme_estserving_id, cp_1.fechatraslado, cp_1.exme_procedencia_id, cp_1.isgenerated, cp_1.statuseleg, cp_1.instruccionalta, cp_1.nombrearchivo, cp_1.formatoarchivo, cp_1.archivo, cp_1.informealta, cp_1.exme_medico2_id, cp_1.exme_especialidad2_id, cp_1.exme_dischargestatus_id, cp_1.resstatus, cp_1.billingstatus, cp_1.exme_tipoprod_id, cp_1.drg, cp_1.exme_tipopaciente_id, cp_1.exme_arrivalmode_id, cp_1.exme_admittype_id, cp_1.exme_admitsource_id, cp_1.isnewborn, cp_1.exme_beneficiosh_id, cp_1.exme_estservprov_id, cp_1.billdate, cp_1.exme_area_id, cp_1.ref_unit_id, cp_1.encounterstatus, cp_1.exme_medicorefer_id, cp_1.exme_especialidadrefer_id, cp_1.exme_ctapacrefer_id, cp_1.isidentifier, cp_1.email, cp_1.requester, cp_1.fechaenv, cp_1.departuredate, cp_1.exme_pos_id, cp_1.exme_drg_id, cp_1.noinsurancecoverage, cp_1.nostatementage, cp_1.validonqueue, cp_1.exme_accompaniedby_id, cp_1.exme_transport_mode_id, cp_1.exme_discharged_via_id, cp_1.comments, cp_1.exme_institucion_id, cp_1.billingtype, cp_1.coded, cp_1.codingdate, cp_1.codedprof, cp_1.codingdateprof, cp_1.institutionalstatus, cp_1.institutionalstep, cp_1.isvalid, cp_1.nombre_pac, cp_1.mrn, cp_1.processingpaq, cp_1.processingpaq2, cp_1.isclosed, cp_1.exme_eventmerge_id, cp_1.fallrisk, cp_1.triage, cp_1.apollo_policy, cp_1.apollo_claim
  • Recheck Cond: (cp_1.ad_org_id = $17)
  • Filter: ((COALESCE(cp_1.fechaalta, cp_1.fechacierre) IS NULL) AND (cp_1.fechacancel IS NULL) AND (cp_1.isactive = 'Y'::bpchar) AND ((cp_1.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 26064
  • Heap Blocks: exact=19258
  • Buffers: shared hit=19332
48. 6.274 6.274 ↓ 2.0 26,112 1

Bitmap Index Scan on ender_exme_ctapac_active_client_org (cost=0.00..247.78 rows=13,247 width=0) (actual time=6.274..6.274 rows=26,112 loops=1)

  • Index Cond: (cp_1.ad_org_id = $17)
  • Buffers: shared hit=74
49. 3.408 3.408 ↓ 8.0 32 48

Index Scan using exme_ctapacdet_cargpend on public.exme_ctapacdet cpd (cost=0.56..29.20 rows=4 width=30) (actual time=0.012..0.071 rows=32 loops=48)

  • Output: cpd.exme_ctapacdet_id, cpd.ad_client_id, cpd.ad_org_id, cpd.isactive, cpd.created, cpd.createdby, cpd.updated, cpd.updatedby, cpd.exme_ctapac_id, cpd.line, cpd.dateordered, cpd.datepromised, cpd.datedelivered, cpd.dateinvoiced, cpd.description, cpd.m_product_id, cpd.m_warehouse_id, cpd.c_uom_id, cpd.qtyordered, cpd.qtyreserved, cpd.qtydelivered, cpd.qtyinvoiced, cpd.m_shipper_id, cpd.c_currency_id, cpd.costo, cpd.pricelist, cpd.priceactual, cpd.pricelimit, cpd.linenetamt, cpd.discount, cpd.freightamt, cpd.c_charge_id, cpd.chargeamt, cpd.c_tax_id, cpd.s_resourceassignment_id, cpd.m_attributesetinstance_id, cpd.isdescription, cpd.ref_ctapacdet_id, cpd.exme_ctapacext_id, cpd.m_inoutline_id, cpd.ad_orgtrx_id, cpd.exme_cdiariodet_id, cpd.exme_planmedline_id, cpd.m_movementline_id, cpd.tipoarea, cpd.exme_area_id, cpd.pricelistinv, cpd.priceactualinv, cpd.pricelimitinv, cpd.usarfactor, cpd.exme_paqbase_version_id, cpd.secuencia, cpd.m_warehouse_sol_id, cpd.qtyentered, cpd.cgoprocesado, cpd.exme_conceptofac_id, cpd.exme_productfam_id, cpd.preciopublico, cpd.c_taxpublico_id, cpd.productcategory, cpd.productdescription, cpd.productvalue, cpd.sedevolvio, cpd.qtypendiente, cpd.qtypaquete, cpd.exme_esqdesline_id, cpd.ref_ctapac_id, cpd.m_movement_id, cpd.m_inout_id, cpd.taxamt, cpd.discountamt, cpd.invoice_uom_id, cpd.tipolinea, cpd.calcularprecio, cpd.convenio_id, cpd.noline, cpd.discountfam, cpd.ad_user_id, cpd.visible, cpd.ad_session_id, cpd.isfacturado, cpd.serie, cpd.ref_exme_ctapacdet_id, cpd.borrarconv, cpd.exme_tratamientos_sesion_id, cpd.ad_pinstance_id, cpd.exme_actpacienteind_id, cpd.exme_revenuecode_id, cpd.ar, cpd.exme_pos_id, cpd.condition, cpd.billingtype, cpd.discounttaxamt, cpd.exme_cancelcharges_id, cpd.m_locator_id, cpd.costaverage, cpd.coststandard, cpd.pricelastpo, cpd.detailtax, cpd.source_id, cpd.qtydoses, cpd.dailycharge, cpd.c_taxcategory_id, cpd.costingmethod, cpd.qtyconversion, cpd.parent_id, cpd.type, cpd.exme_medico_id, cpd.function
  • Index Cond: ((cpd.exme_ctapac_id = cp_1.exme_ctapac_id) AND (cpd.ad_org_id = $16) AND (cpd.isactive = 'Y'::bpchar))
  • Filter: ((cpd.tipolinea <> 'EX'::bpchar) AND (cpd.sedevolvio = 'N'::bpchar))
  • Rows Removed by Filter: 7
  • Buffers: shared hit=1007
50. 6.228 6.228 ↑ 1.0 1 1,557

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe (cost=0.43..1.51 rows=1 width=6) (actual time=0.004..0.004 rows=1 loops=1,557)

  • Output: cpe.exme_ctapacext_id, cpe.ad_client_id, cpe.ad_org_id, cpe.isactive, cpe.created, cpe.createdby, cpe.updated, cpe.updatedby, cpe.documentno, cpe.docstatus, cpe.docaction, cpe.processing, cpe.processed, cpe.c_doctype_id, cpe.c_doctypetarget_id, cpe.description, cpe.isapproved, cpe.isprinted, cpe.dateordered, cpe.dateacct, cpe.c_bpartner_id, cpe.c_bpartner_location_id, cpe.c_charge_id, cpe.chargeamt, cpe.totallines, cpe.grandtotal, cpe.ad_user_id, cpe.ad_orgtrx_id, cpe.ref_ctapacext_id, cpe.desctoglobal, cpe.coaseguro, cpe.deducible, cpe.c_invoice_id, cpe.exme_ctapac_id, cpe.rfc, cpe.extensionno, cpe.iscoasegpercent, cpe.isdeducincoaseg, cpe.desctoglobalamt, cpe.observacion, cpe.c_location_id, cpe.anticipo, cpe.coaseguromed, cpe.copago, cpe.taxamt, cpe.coaseguroamt, cpe.deducibleamt, cpe.coaseguromedamt, cpe.copagoamt, cpe.isdiscpercent, cpe.isdeducpercent, cpe.iscoasmedpercent, cpe.iscoppercent, cpe.conftype, cpe.institutionalstatus, cpe.institutionalstep, cpe.professionalstatus, cpe.professionalstep, cpe.chargestatus, cpe.discounttaxamt, cpe.isorderfaclinecategory, cpe.coasegurotax, cpe.deducibletax, cpe.coaseguromedtax, cpe.copagotax, cpe.emprelationship
  • Index Cond: (cpe.exme_ctapacext_id = cpd.exme_ctapacext_id)
  • Filter: (cpe.extensionno = '0'::numeric)
  • Rows Removed by Filter: 0
  • Buffers: shared hit=6228
51. 1.557 65.238 ↓ 140.8 1,549 1

WindowAgg (cost=0.41..0.66 rows=11 width=48) (actual time=64.122..65.238 rows=1,549 loops=1)

  • Output: c0.exme_ctapac_id, (sum(c0.linenetamt) OVER (?) + sum(c0.taxamt) OVER (?))
  • Buffers: shared hit=26567
52. 0.689 63.681 ↓ 140.8 1,549 1

Sort (cost=0.41..0.44 rows=11 width=80) (actual time=63.539..63.681 rows=1,549 loops=1)

  • Output: c0.exme_ctapac_id, c0.linenetamt, c0.taxamt
  • Sort Key: c0.exme_ctapac_id
  • Sort Method: quicksort Memory: 170kB
  • Buffers: shared hit=26567
53. 62.992 62.992 ↓ 140.8 1,549 1

CTE Scan on c0 (cost=0.00..0.22 rows=11 width=80) (actual time=61.700..62.992 rows=1,549 loops=1)

  • Output: c0.exme_ctapac_id, c0.linenetamt, c0.taxamt
  • Buffers: shared hit=26567
54.          

CTE cargos1

55. 0.017 64.906 ↓ 0.0 0 1

HashAggregate (cost=32,619.15..32,619.21 rows=5 width=48) (actual time=64.905..64.906 rows=0 loops=1)

  • Output: c1.exme_ctapac_id, ((sum(c1.linenetamt) OVER (?) + sum(c1.taxamt) OVER (?)))
  • Group Key: c1.exme_ctapac_id, (sum(c1.linenetamt) OVER (?) + sum(c1.taxamt) OVER (?))
  • Buffers: shared hit=25705 read=862
56.          

CTE c1

57. 0.002 64.843 ↓ 0.0 0 1

Unique (cost=32,618.78..32,618.85 rows=5 width=82) (actual time=64.843..64.843 rows=0 loops=1)

  • Output: cpd_1.exme_ctapac_id, cpd_1.exme_ctapacdet_id, (COALESCE(cpd_1.linenetamt, '0'::numeric)), (COALESCE(cpd_1.taxamt, '0'::numeric)), cpe_1.c_invoice_id
  • Buffers: shared hit=25705 read=862
58.          

Initplan (forUnique)

59. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on params params_5 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: params_5.org_id
60. 0.005 0.005 ↑ 1.0 1 1

CTE Scan on params params_6 (cost=0.00..0.02 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=1)

  • Output: params_6.org_id
61. 0.011 64.830 ↓ 0.0 0 1

Sort (cost=32,618.74..32,618.75 rows=5 width=82) (actual time=64.830..64.830 rows=0 loops=1)

  • Output: cpd_1.exme_ctapac_id, cpd_1.exme_ctapacdet_id, (COALESCE(cpd_1.linenetamt, '0'::numeric)), (COALESCE(cpd_1.taxamt, '0'::numeric)), cpe_1.c_invoice_id
  • Sort Key: cpd_1.exme_ctapac_id, cpd_1.exme_ctapacdet_id, (COALESCE(cpd_1.linenetamt, '0'::numeric)), (COALESCE(cpd_1.taxamt, '0'::numeric)), cpe_1.c_invoice_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=25705 read=862
62. 1.679 64.819 ↓ 0.0 0 1

Nested Loop (cost=248.78..32,618.68 rows=5 width=82) (actual time=64.819..64.819 rows=0 loops=1)

  • Output: cpd_1.exme_ctapac_id, cpd_1.exme_ctapacdet_id, COALESCE(cpd_1.linenetamt, '0'::numeric), COALESCE(cpd_1.taxamt, '0'::numeric), cpe_1.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=25705 read=862
63. 0.484 56.912 ↓ 81.9 1,557 1

Nested Loop (cost=248.35..32,589.95 rows=19 width=30) (actual time=23.387..56.912 rows=1,557 loops=1)

  • Output: cpd_1.exme_ctapac_id, cpd_1.exme_ctapacdet_id, cpd_1.linenetamt, cpd_1.taxamt, cpd_1.exme_ctapacext_id
  • Buffers: shared hit=19514 read=825
64. 41.837 47.980 ↑ 1.4 48 1

Bitmap Heap Scan on public.exme_ctapac cp_2 (cost=247.79..30,660.38 rows=66 width=6) (actual time=16.376..47.980 rows=48 loops=1)

  • Output: cp_2.exme_ctapac_id, cp_2.ad_client_id, cp_2.ad_org_id, cp_2.isactive, cp_2.created, cp_2.createdby, cp_2.updated, cp_2.updatedby, cp_2.documentno, cp_2.docstatus, cp_2.docaction, cp_2.processing, cp_2.processed, cp_2.c_doctype_id, cp_2.c_doctypetarget_id, cp_2.description, cp_2.isapproved, cp_2.iscreditapproved, cp_2.isinvoiced, cp_2.isprinted, cp_2.dateordered, cp_2.dateprinted, cp_2.dateacct, cp_2.priorityrule, cp_2.grandtotal, cp_2.m_pricelist_id, cp_2.c_campaign_id, cp_2.c_project_id, cp_2.c_activity_id, cp_2.ad_user_id, cp_2.ad_orgtrx_id, cp_2.user1_id, cp_2.user2_id, cp_2.fechacancel, cp_2.exme_paciente_id, cp_2.exme_especialidad_id, cp_2.exme_motivocita_id, cp_2.estatus, cp_2.exme_medico_id, cp_2.ref_ctapac_id, cp_2.c_currency_id, cp_2.ad_printformat_id, cp_2.impcontrato, cp_2.impconsent, cp_2.impdatos, cp_2.impbrazalete, cp_2.exme_diagnostico_id, cp_2.exme_cama_id, cp_2.tipoarea, cp_2.fechacargodiario, cp_2.fechacierre, cp_2.exme_paqbase_version_id, cp_2.exme_ctapacext_id, cp_2.exme_estserv_id, cp_2.isuso, cp_2.isbloqueada, cp_2.isautorizada, cp_2.diagnostico_ingreso, cp_2.fechaalta, cp_2.actualizadoalta, cp_2.statusalta, cp_2.exme_camaing_id, cp_2.fechaprealta, cp_2.actualizadoprealta, cp_2.isfactespec, cp_2.ref_ctapacfam_id, cp_2.exme_descpreciofijo_id, cp_2.tiposangre, cp_2.exme_tipotrasplante_id, cp_2.exme_motivoegreso_id, cp_2.casosmedicos, cp_2.exme_estserving_id, cp_2.fechatraslado, cp_2.exme_procedencia_id, cp_2.isgenerated, cp_2.statuseleg, cp_2.instruccionalta, cp_2.nombrearchivo, cp_2.formatoarchivo, cp_2.archivo, cp_2.informealta, cp_2.exme_medico2_id, cp_2.exme_especialidad2_id, cp_2.exme_dischargestatus_id, cp_2.resstatus, cp_2.billingstatus, cp_2.exme_tipoprod_id, cp_2.drg, cp_2.exme_tipopaciente_id, cp_2.exme_arrivalmode_id, cp_2.exme_admittype_id, cp_2.exme_admitsource_id, cp_2.isnewborn, cp_2.exme_beneficiosh_id, cp_2.exme_estservprov_id, cp_2.billdate, cp_2.exme_area_id, cp_2.ref_unit_id, cp_2.encounterstatus, cp_2.exme_medicorefer_id, cp_2.exme_especialidadrefer_id, cp_2.exme_ctapacrefer_id, cp_2.isidentifier, cp_2.email, cp_2.requester, cp_2.fechaenv, cp_2.departuredate, cp_2.exme_pos_id, cp_2.exme_drg_id, cp_2.noinsurancecoverage, cp_2.nostatementage, cp_2.validonqueue, cp_2.exme_accompaniedby_id, cp_2.exme_transport_mode_id, cp_2.exme_discharged_via_id, cp_2.comments, cp_2.exme_institucion_id, cp_2.billingtype, cp_2.coded, cp_2.codingdate, cp_2.codedprof, cp_2.codingdateprof, cp_2.institutionalstatus, cp_2.institutionalstep, cp_2.isvalid, cp_2.nombre_pac, cp_2.mrn, cp_2.processingpaq, cp_2.processingpaq2, cp_2.isclosed, cp_2.exme_eventmerge_id, cp_2.fallrisk, cp_2.triage, cp_2.apollo_policy, cp_2.apollo_claim
  • Recheck Cond: (cp_2.ad_org_id = $23)
  • Filter: ((COALESCE(cp_2.fechaalta, cp_2.fechacierre) IS NULL) AND (cp_2.fechacancel IS NULL) AND (cp_2.isactive = 'Y'::bpchar) AND ((cp_2.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 26064
  • Heap Blocks: exact=19258
  • Buffers: shared hit=19332
65. 6.143 6.143 ↓ 2.0 26,112 1

Bitmap Index Scan on ender_exme_ctapac_active_client_org (cost=0.00..247.78 rows=13,247 width=0) (actual time=6.143..6.143 rows=26,112 loops=1)

  • Index Cond: (cp_2.ad_org_id = $23)
  • Buffers: shared hit=74
66. 8.448 8.448 ↓ 8.0 32 48

Index Scan using exme_ctapacdet_cargpend on public.exme_ctapacdet cpd_1 (cost=0.56..29.20 rows=4 width=30) (actual time=0.026..0.176 rows=32 loops=48)

  • Output: cpd_1.exme_ctapacdet_id, cpd_1.ad_client_id, cpd_1.ad_org_id, cpd_1.isactive, cpd_1.created, cpd_1.createdby, cpd_1.updated, cpd_1.updatedby, cpd_1.exme_ctapac_id, cpd_1.line, cpd_1.dateordered, cpd_1.datepromised, cpd_1.datedelivered, cpd_1.dateinvoiced, cpd_1.description, cpd_1.m_product_id, cpd_1.m_warehouse_id, cpd_1.c_uom_id, cpd_1.qtyordered, cpd_1.qtyreserved, cpd_1.qtydelivered, cpd_1.qtyinvoiced, cpd_1.m_shipper_id, cpd_1.c_currency_id, cpd_1.costo, cpd_1.pricelist, cpd_1.priceactual, cpd_1.pricelimit, cpd_1.linenetamt, cpd_1.discount, cpd_1.freightamt, cpd_1.c_charge_id, cpd_1.chargeamt, cpd_1.c_tax_id, cpd_1.s_resourceassignment_id, cpd_1.m_attributesetinstance_id, cpd_1.isdescription, cpd_1.ref_ctapacdet_id, cpd_1.exme_ctapacext_id, cpd_1.m_inoutline_id, cpd_1.ad_orgtrx_id, cpd_1.exme_cdiariodet_id, cpd_1.exme_planmedline_id, cpd_1.m_movementline_id, cpd_1.tipoarea, cpd_1.exme_area_id, cpd_1.pricelistinv, cpd_1.priceactualinv, cpd_1.pricelimitinv, cpd_1.usarfactor, cpd_1.exme_paqbase_version_id, cpd_1.secuencia, cpd_1.m_warehouse_sol_id, cpd_1.qtyentered, cpd_1.cgoprocesado, cpd_1.exme_conceptofac_id, cpd_1.exme_productfam_id, cpd_1.preciopublico, cpd_1.c_taxpublico_id, cpd_1.productcategory, cpd_1.productdescription, cpd_1.productvalue, cpd_1.sedevolvio, cpd_1.qtypendiente, cpd_1.qtypaquete, cpd_1.exme_esqdesline_id, cpd_1.ref_ctapac_id, cpd_1.m_movement_id, cpd_1.m_inout_id, cpd_1.taxamt, cpd_1.discountamt, cpd_1.invoice_uom_id, cpd_1.tipolinea, cpd_1.calcularprecio, cpd_1.convenio_id, cpd_1.noline, cpd_1.discountfam, cpd_1.ad_user_id, cpd_1.visible, cpd_1.ad_session_id, cpd_1.isfacturado, cpd_1.serie, cpd_1.ref_exme_ctapacdet_id, cpd_1.borrarconv, cpd_1.exme_tratamientos_sesion_id, cpd_1.ad_pinstance_id, cpd_1.exme_actpacienteind_id, cpd_1.exme_revenuecode_id, cpd_1.ar, cpd_1.exme_pos_id, cpd_1.condition, cpd_1.billingtype, cpd_1.discounttaxamt, cpd_1.exme_cancelcharges_id, cpd_1.m_locator_id, cpd_1.costaverage, cpd_1.coststandard, cpd_1.pricelastpo, cpd_1.detailtax, cpd_1.source_id, cpd_1.qtydoses, cpd_1.dailycharge, cpd_1.c_taxcategory_id, cpd_1.costingmethod, cpd_1.qtyconversion, cpd_1.parent_id, cpd_1.type, cpd_1.exme_medico_id, cpd_1.function
  • Index Cond: ((cpd_1.exme_ctapac_id = cp_2.exme_ctapac_id) AND (cpd_1.ad_org_id = $22) AND (cpd_1.isactive = 'Y'::bpchar))
  • Filter: ((cpd_1.tipolinea <> 'EX'::bpchar) AND (cpd_1.sedevolvio = 'N'::bpchar))
  • Rows Removed by Filter: 7
  • Buffers: shared hit=182 read=825
67. 6.228 6.228 ↓ 0.0 0 1,557

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe_1 (cost=0.43..1.51 rows=1 width=12) (actual time=0.004..0.004 rows=0 loops=1,557)

  • Output: cpe_1.exme_ctapacext_id, cpe_1.ad_client_id, cpe_1.ad_org_id, cpe_1.isactive, cpe_1.created, cpe_1.createdby, cpe_1.updated, cpe_1.updatedby, cpe_1.documentno, cpe_1.docstatus, cpe_1.docaction, cpe_1.processing, cpe_1.processed, cpe_1.c_doctype_id, cpe_1.c_doctypetarget_id, cpe_1.description, cpe_1.isapproved, cpe_1.isprinted, cpe_1.dateordered, cpe_1.dateacct, cpe_1.c_bpartner_id, cpe_1.c_bpartner_location_id, cpe_1.c_charge_id, cpe_1.chargeamt, cpe_1.totallines, cpe_1.grandtotal, cpe_1.ad_user_id, cpe_1.ad_orgtrx_id, cpe_1.ref_ctapacext_id, cpe_1.desctoglobal, cpe_1.coaseguro, cpe_1.deducible, cpe_1.c_invoice_id, cpe_1.exme_ctapac_id, cpe_1.rfc, cpe_1.extensionno, cpe_1.iscoasegpercent, cpe_1.isdeducincoaseg, cpe_1.desctoglobalamt, cpe_1.observacion, cpe_1.c_location_id, cpe_1.anticipo, cpe_1.coaseguromed, cpe_1.copago, cpe_1.taxamt, cpe_1.coaseguroamt, cpe_1.deducibleamt, cpe_1.coaseguromedamt, cpe_1.copagoamt, cpe_1.isdiscpercent, cpe_1.isdeducpercent, cpe_1.iscoasmedpercent, cpe_1.iscoppercent, cpe_1.conftype, cpe_1.institutionalstatus, cpe_1.institutionalstep, cpe_1.professionalstatus, cpe_1.professionalstep, cpe_1.chargestatus, cpe_1.discounttaxamt, cpe_1.isorderfaclinecategory, cpe_1.coasegurotax, cpe_1.deducibletax, cpe_1.coaseguromedtax, cpe_1.copagotax, cpe_1.emprelationship
  • Index Cond: (cpe_1.exme_ctapacext_id = cpd_1.exme_ctapacext_id)
  • Filter: ((cpe_1.c_invoice_id IS NULL) AND (cpe_1.extensionno > '0'::numeric))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=6191 read=37
68. 0.015 64.889 ↓ 0.0 0 1

WindowAgg (cost=0.16..0.27 rows=5 width=48) (actual time=64.889..64.889 rows=0 loops=1)

  • Output: c1.exme_ctapac_id, (sum(c1.linenetamt) OVER (?) + sum(c1.taxamt) OVER (?))
  • Buffers: shared hit=25705 read=862
69. 0.019 64.874 ↓ 0.0 0 1

Sort (cost=0.16..0.17 rows=5 width=80) (actual time=64.874..64.874 rows=0 loops=1)

  • Output: c1.exme_ctapac_id, c1.linenetamt, c1.taxamt
  • Sort Key: c1.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=25705 read=862
70. 64.855 64.855 ↓ 0.0 0 1

CTE Scan on c1 (cost=0.00..0.10 rows=5 width=80) (actual time=64.855..64.855 rows=0 loops=1)

  • Output: c1.exme_ctapac_id, c1.linenetamt, c1.taxamt
  • Buffers: shared hit=25705 read=862
71.          

CTE cargos1f

72. 0.051 2,213.205 ↓ 8.0 8 1

HashAggregate (cost=188,123.11..188,123.12 rows=1 width=112) (actual time=2,213.202..2,213.205 rows=8 loops=1)

  • Output: cf.exme_ctapac_id, (sum(cf.subtotal) OVER (?)), (sum(cf.iva) OVER (?)), (sum(cf.facturado) OVER (?))
  • Group Key: cf.exme_ctapac_id, sum(cf.subtotal) OVER (?), sum(cf.iva) OVER (?), sum(cf.facturado) OVER (?)
  • Buffers: shared hit=380483 read=171335 written=14
73.          

CTE cargosfact

74. 0.002 2,212.974 ↓ 8.0 8 1

Unique (cost=188,123.03..188,123.05 rows=1 width=109) (actual time=2,212.956..2,212.974 rows=8 loops=1)

  • Output: i.exme_ctapac_id, (COALESCE(i.totallines, '0'::numeric)), (COALESCE(i.taxamt, '0'::numeric)), (COALESCE(i.grandtotal, '0'::numeric)), i.c_invoice_id
  • Buffers: shared hit=380483 read=171335 written=14
75.          

Initplan (forUnique)

76. 0.020 0.020 ↑ 1.0 1 1

CTE Scan on params params_7 (cost=0.00..0.02 rows=1 width=32) (actual time=0.020..0.020 rows=1 loops=1)

  • Output: params_7.org_id
77. 0.010 0.010 ↑ 1.0 1 1

CTE Scan on params params_8 (cost=0.00..0.02 rows=1 width=32) (actual time=0.009..0.010 rows=1 loops=1)

  • Output: params_8.org_id
78. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params params_9 (cost=0.00..0.02 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=1)

  • Output: params_9.org_id
79. 0.060 2,212.938 ↓ 8.0 8 1

Sort (cost=188,122.97..188,122.97 rows=1 width=109) (actual time=2,212.937..2,212.938 rows=8 loops=1)

  • Output: i.exme_ctapac_id, (COALESCE(i.totallines, '0'::numeric)), (COALESCE(i.taxamt, '0'::numeric)), (COALESCE(i.grandtotal, '0'::numeric)), i.c_invoice_id
  • Sort Key: i.exme_ctapac_id, (COALESCE(i.totallines, '0'::numeric)), (COALESCE(i.taxamt, '0'::numeric)), (COALESCE(i.grandtotal, '0'::numeric)), i.c_invoice_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=380483 read=171335 written=14
80. 0.056 2,212.878 ↓ 8.0 8 1

Result (cost=126,467.54..188,122.96 rows=1 width=109) (actual time=1,700.350..2,212.878 rows=8 loops=1)

  • Output: i.exme_ctapac_id, COALESCE(i.totallines, '0'::numeric), COALESCE(i.taxamt, '0'::numeric), COALESCE(i.grandtotal, '0'::numeric), i.c_invoice_id
  • One-Time Filter: ($29 = $32)
  • Buffers: shared hit=380483 read=171335 written=14
81. 32.981 2,212.822 ↓ 8.0 8 1

Nested Loop (cost=126,467.54..188,122.96 rows=1 width=31) (actual time=1,700.307..2,212.822 rows=8 loops=1)

  • Output: i.exme_ctapac_id, i.totallines, i.taxamt, i.grandtotal, i.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=380483 read=171335 written=14
82. 76.817 1,955.176 ↓ 6,419.0 32,095 1

Nested Loop (cost=126,467.11..188,119.99 rows=5 width=37) (actual time=200.935..1,955.176 rows=32,095 loops=1)

  • Output: i.exme_ctapac_id, i.totallines, i.taxamt, i.grandtotal, i.c_invoice_id, cpe_2.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=263926 read=159334 written=14
83. 201.597 1,562.591 ↓ 11,695.1 105,256 1

Hash Join (cost=126,466.69..188,074.55 rows=9 width=38) (actual time=200.812..1,562.591 rows=105,256 loops=1)

  • Output: i.exme_ctapac_id, i.totallines, i.taxamt, i.grandtotal, i.c_invoice_id, i.exme_ctapacext_id
  • Inner Unique: true
  • Hash Cond: (i.c_doctype_id = dt_1.c_doctype_id)
  • Buffers: shared hit=160504 read=134279 written=12
84. 1,192.543 1,360.689 ↓ 13.9 239,517 1

Index Scan using ender_c_invoice_validation on public.c_invoice i (cost=126,428.97..187,991.73 rows=17,172 width=44) (actual time=200.442..1,360.689 rows=239,517 loops=1)

  • Output: i.c_invoice_id, i.ad_client_id, i.ad_org_id, i.isactive, i.created, i.createdby, i.updated, i.updatedby, i.issotrx, i.documentno, i.docstatus, i.docaction, i.processing, i.processed, i.posted, i.c_doctype_id, i.c_doctypetarget_id, i.c_order_id, i.description, i.isapproved, i.istransferred, i.isprinted, i.salesrep_id, i.dateinvoiced, i.dateprinted, i.dateacct, i.c_bpartner_id, i.c_bpartner_location_id, i.poreference, i.isdiscountprinted, i.dateordered, i.c_currency_id, i.paymentrule, i.c_paymentterm_id, i.c_charge_id, i.chargeamt, i.totallines, i.grandtotal, i.m_pricelist_id, i.istaxincluded, i.c_campaign_id, i.c_project_id, i.c_activity_id, i.ispaid, i.c_payment_id, i.c_cashline_id, i.createfrom, i.generateto, i.sendemail, i.ad_user_id, i.copyfrom, i.isselfservice, i.ad_orgtrx_id, i.user1_id, i.user2_id, i.c_conversiontype_id, i.ispayschedulevalid, i.ref_invoice_id, i.isindispute, i.exme_ctapacext_id, i.descfromaseg, i.precfromaseg, i.documentnoext, i.afecta_caja, i.c_cashbook_id, i.discountporcent, i.discountamt, i.address1, i.address2, i.city, i.postal, i.c_country_id, i.c_region_id, i.address3, i.exme_paciente_id, i.exme_medico_id, i.nombre_medico, i.nombre_paciente, i.exme_estserv_id, i.c_cash_id, i.canceledby, i.motivocancel, i.exme_motivocancel_id, i.isprintedpre, i.updatedbycancel, i.numext, i.numin, i.sexo, i.fechanac, i.invoicephone, i.exme_towncouncil_id, i.tipooperacion, i.observation, i.dunninggrace, i.m_rma_id, i.c_dunninglevel_id, i.invoicecollectiontype, i.reversal_id, i.verpoliza, i.isgenerated, i.globaldiscount, i.sello, i.cadena, i.exme_ctapac_id, i.conftype, i.multiple_id, i.ismultiple, i.partner, i.uuid, i.estserv, i.prepayment, i.backoffice, i.discounttaxamt, i.taxamt, i.exme_claimpayment_id, i.coaseguro, i.deducible, i.coaseguromed, i.copago, i.coaseguroamt, i.deducibleamt, i.coaseguromedamt, i.copagoamt, i.ref_invoice_sales_id, i.isinvoiced, i.isorderfaclinecategory, i.trxtype, i.rebate, i.sortby, i.addenda, i.sellosat, i.certificadosat, i.nocertificado, i.certificado, i.rate, i.m_inout_id, i.generatedfrom, i.typeacct, i.detailpayment, i.c_cash_cancel_id, i.datecanceled, i.exme_areacaja_id, i.accountno, i.post, i.statusuuid, i.canceldescription, i.versionno, i.emprelationship, i.perception, i.comp_ditto, i.perceptioniva, i.afip, i.date_comp, i.typefac_ditto
  • Index Cond: ((i.isactive = 'Y'::bpchar) AND (i.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (i.issotrx = 'Y'::bpchar) AND (i.ad_org_id = $32))
  • Filter: ((i.c_doctype_id > '0'::numeric) AND (NOT (hashed SubPlan 16)) AND (i.c_doctype_id > '0'::numeric))
  • Rows Removed by Filter: 1842
  • Buffers: shared hit=160481 read=134273 written=12
85.          

SubPlan (forIndex Scan)

86. 9.112 168.146 ↓ 116.4 59,695 1

Nested Loop (cost=0.56..126,427.25 rows=513 width=7) (actual time=0.131..168.146 rows=59,695 loops=1)

  • Output: ssi.ref_invoice_id
  • Buffers: shared hit=64297
87. 2.709 2.709 ↓ 1.6 169 1

Seq Scan on public.c_doctype dt (cost=0.00..347.14 rows=104 width=6) (actual time=0.032..2.709 rows=169 loops=1)

  • Output: dt.c_doctype_id, dt.ad_client_id, dt.ad_org_id, dt.isactive, dt.created, dt.createdby, dt.updated, dt.updatedby, dt.name, dt.printname, dt.description, dt.docbasetype, dt.issotrx, dt.docsubtypeso, dt.hasproforma, dt.c_doctypeproforma_id, dt.c_doctypeshipment_id, dt.c_doctypeinvoice_id, dt.isdocnocontrolled, dt.docnosequence_id, dt.gl_category_id, dt.hascharges, dt.documentnote, dt.isdefault, dt.documentcopies, dt.ad_printformat_id, dt.isdefaultcounterdoc, dt.isshipconfirm, dt.ispickqaconfirm, dt.isintransit, dt.issplitwhendifference, dt.c_doctypedifference_id, dt.iscreatecounter, dt.isindexed, dt.definitesequence_id, dt.isoverwriteseqoncomplete, dt.isoverwritedateoncomplete, dt.exme_typevouchercode_id, dt.exme_relationtypecode_id, dt.type
  • Filter: ((dt.docsubtypeso IS NULL) AND (dt.isactive = 'Y'::bpchar) AND (dt.docbasetype = 'ARC'::bpchar))
  • Rows Removed by Filter: 9174
  • Buffers: shared hit=207
88. 156.325 156.325 ↓ 1.5 353 169

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi (cost=0.56..1,209.92 rows=239 width=13) (actual time=0.038..0.925 rows=353 loops=169)

  • Output: ssi.isactive, ssi.c_doctype_id, ssi.docstatus, ssi.issotrx, ssi.c_invoice_id, ssi.ref_invoice_id, ssi.trxtype, ssi.issotrx
  • Index Cond: ((ssi.isactive = 'Y'::bpchar) AND (ssi.c_doctype_id = dt.c_doctype_id) AND (ssi.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi.issotrx = 'Y'::bpchar) AND (ssi.trxtype = ANY ('{N,X}'::bpchar[])))
  • Heap Fetches: 59695
  • Buffers: shared hit=64090
89. 0.070 0.305 ↓ 33.6 168 1

Hash (cost=37.66..37.66 rows=5 width=6) (actual time=0.305..0.305 rows=168 loops=1)

  • Output: dt_1.c_doctype_id
  • Buckets: 1024 Batches: 1 Memory Usage: 15kB
  • Buffers: shared hit=23 read=6
90. 0.106 0.235 ↓ 33.6 168 1

Bitmap Heap Scan on public.c_doctype dt_1 (cost=16.62..37.66 rows=5 width=6) (actual time=0.155..0.235 rows=168 loops=1)

  • Output: dt_1.c_doctype_id
  • Recheck Cond: ((dt_1.docsubtypeso = 'SR'::bpchar) AND (dt_1.docbasetype = 'ARI'::bpchar))
  • Filter: (dt_1.isactive = 'Y'::bpchar)
  • Heap Blocks: exact=23
  • Buffers: shared hit=23 read=6
91. 0.005 0.129 ↓ 0.0 0 1

BitmapAnd (cost=16.62..16.62 rows=6 width=0) (actual time=0.129..0.129 rows=0 loops=1)

  • Buffers: shared read=6
92. 0.069 0.069 ↑ 1.0 168 1

Bitmap Index Scan on c_doctype_docsubtypeso (cost=0.00..5.54 rows=168 width=0) (actual time=0.069..0.069 rows=168 loops=1)

  • Index Cond: (dt_1.docsubtypeso = 'SR'::bpchar)
  • Buffers: shared read=3
93. 0.055 0.055 ↑ 1.0 338 1

Bitmap Index Scan on c_doctype_idx (cost=0.00..10.82 rows=338 width=0) (actual time=0.055..0.055 rows=338 loops=1)

  • Index Cond: (dt_1.docbasetype = 'ARI'::bpchar)
  • Buffers: shared read=3
94. 315.768 315.768 ↓ 0.0 0 105,256

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe_2 (cost=0.43..5.05 rows=1 width=12) (actual time=0.003..0.003 rows=0 loops=105,256)

  • Output: cpe_2.exme_ctapacext_id, cpe_2.ad_client_id, cpe_2.ad_org_id, cpe_2.isactive, cpe_2.created, cpe_2.createdby, cpe_2.updated, cpe_2.updatedby, cpe_2.documentno, cpe_2.docstatus, cpe_2.docaction, cpe_2.processing, cpe_2.processed, cpe_2.c_doctype_id, cpe_2.c_doctypetarget_id, cpe_2.description, cpe_2.isapproved, cpe_2.isprinted, cpe_2.dateordered, cpe_2.dateacct, cpe_2.c_bpartner_id, cpe_2.c_bpartner_location_id, cpe_2.c_charge_id, cpe_2.chargeamt, cpe_2.totallines, cpe_2.grandtotal, cpe_2.ad_user_id, cpe_2.ad_orgtrx_id, cpe_2.ref_ctapacext_id, cpe_2.desctoglobal, cpe_2.coaseguro, cpe_2.deducible, cpe_2.c_invoice_id, cpe_2.exme_ctapac_id, cpe_2.rfc, cpe_2.extensionno, cpe_2.iscoasegpercent, cpe_2.isdeducincoaseg, cpe_2.desctoglobalamt, cpe_2.observacion, cpe_2.c_location_id, cpe_2.anticipo, cpe_2.coaseguromed, cpe_2.copago, cpe_2.taxamt, cpe_2.coaseguroamt, cpe_2.deducibleamt, cpe_2.coaseguromedamt, cpe_2.copagoamt, cpe_2.isdiscpercent, cpe_2.isdeducpercent, cpe_2.iscoasmedpercent, cpe_2.iscoppercent, cpe_2.conftype, cpe_2.institutionalstatus, cpe_2.institutionalstep, cpe_2.professionalstatus, cpe_2.professionalstep, cpe_2.chargestatus, cpe_2.discounttaxamt, cpe_2.isorderfaclinecategory, cpe_2.coasegurotax, cpe_2.deducibletax, cpe_2.coaseguromedtax, cpe_2.copagotax, cpe_2.emprelationship
  • Index Cond: (cpe_2.exme_ctapacext_id = i.exme_ctapacext_id)
  • Buffers: shared hit=103422 read=25055 written=2
95. 224.665 224.665 ↓ 0.0 0 32,095

Index Scan using exme_ctapac_pkey on public.exme_ctapac cp_3 (cost=0.42..0.58 rows=1 width=6) (actual time=0.007..0.007 rows=0 loops=32,095)

  • Output: cp_3.exme_ctapac_id, cp_3.ad_client_id, cp_3.ad_org_id, cp_3.isactive, cp_3.created, cp_3.createdby, cp_3.updated, cp_3.updatedby, cp_3.documentno, cp_3.docstatus, cp_3.docaction, cp_3.processing, cp_3.processed, cp_3.c_doctype_id, cp_3.c_doctypetarget_id, cp_3.description, cp_3.isapproved, cp_3.iscreditapproved, cp_3.isinvoiced, cp_3.isprinted, cp_3.dateordered, cp_3.dateprinted, cp_3.dateacct, cp_3.priorityrule, cp_3.grandtotal, cp_3.m_pricelist_id, cp_3.c_campaign_id, cp_3.c_project_id, cp_3.c_activity_id, cp_3.ad_user_id, cp_3.ad_orgtrx_id, cp_3.user1_id, cp_3.user2_id, cp_3.fechacancel, cp_3.exme_paciente_id, cp_3.exme_especialidad_id, cp_3.exme_motivocita_id, cp_3.estatus, cp_3.exme_medico_id, cp_3.ref_ctapac_id, cp_3.c_currency_id, cp_3.ad_printformat_id, cp_3.impcontrato, cp_3.impconsent, cp_3.impdatos, cp_3.impbrazalete, cp_3.exme_diagnostico_id, cp_3.exme_cama_id, cp_3.tipoarea, cp_3.fechacargodiario, cp_3.fechacierre, cp_3.exme_paqbase_version_id, cp_3.exme_ctapacext_id, cp_3.exme_estserv_id, cp_3.isuso, cp_3.isbloqueada, cp_3.isautorizada, cp_3.diagnostico_ingreso, cp_3.fechaalta, cp_3.actualizadoalta, cp_3.statusalta, cp_3.exme_camaing_id, cp_3.fechaprealta, cp_3.actualizadoprealta, cp_3.isfactespec, cp_3.ref_ctapacfam_id, cp_3.exme_descpreciofijo_id, cp_3.tiposangre, cp_3.exme_tipotrasplante_id, cp_3.exme_motivoegreso_id, cp_3.casosmedicos, cp_3.exme_estserving_id, cp_3.fechatraslado, cp_3.exme_procedencia_id, cp_3.isgenerated, cp_3.statuseleg, cp_3.instruccionalta, cp_3.nombrearchivo, cp_3.formatoarchivo, cp_3.archivo, cp_3.informealta, cp_3.exme_medico2_id, cp_3.exme_especialidad2_id, cp_3.exme_dischargestatus_id, cp_3.resstatus, cp_3.billingstatus, cp_3.exme_tipoprod_id, cp_3.drg, cp_3.exme_tipopaciente_id, cp_3.exme_arrivalmode_id, cp_3.exme_admittype_id, cp_3.exme_admitsource_id, cp_3.isnewborn, cp_3.exme_beneficiosh_id, cp_3.exme_estservprov_id, cp_3.billdate, cp_3.exme_area_id, cp_3.ref_unit_id, cp_3.encounterstatus, cp_3.exme_medicorefer_id, cp_3.exme_especialidadrefer_id, cp_3.exme_ctapacrefer_id, cp_3.isidentifier, cp_3.email, cp_3.requester, cp_3.fechaenv, cp_3.departuredate, cp_3.exme_pos_id, cp_3.exme_drg_id, cp_3.noinsurancecoverage, cp_3.nostatementage, cp_3.validonqueue, cp_3.exme_accompaniedby_id, cp_3.exme_transport_mode_id, cp_3.exme_discharged_via_id, cp_3.comments, cp_3.exme_institucion_id, cp_3.billingtype, cp_3.coded, cp_3.codingdate, cp_3.codedprof, cp_3.codingdateprof, cp_3.institutionalstatus, cp_3.institutionalstep, cp_3.isvalid, cp_3.nombre_pac, cp_3.mrn, cp_3.processingpaq, cp_3.processingpaq2, cp_3.isclosed, cp_3.exme_eventmerge_id, cp_3.fallrisk, cp_3.triage, cp_3.apollo_policy, cp_3.apollo_claim
  • Index Cond: (cp_3.exme_ctapac_id = cpe_2.exme_ctapac_id)
  • Filter: ((COALESCE(cp_3.fechaalta, cp_3.fechacierre) IS NULL) AND (cp_3.fechacancel IS NULL) AND (cp_3.ad_org_id = $28) AND (cp_3.isactive = 'Y'::bpchar) AND ((cp_3.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=116557 read=12001
96. 0.133 2,213.154 ↓ 8.0 8 1

WindowAgg (cost=0.03..0.06 rows=1 width=112) (actual time=2,213.126..2,213.154 rows=8 loops=1)

  • Output: cf.exme_ctapac_id, sum(cf.subtotal) OVER (?), sum(cf.iva) OVER (?), sum(cf.facturado) OVER (?)
  • Buffers: shared hit=380483 read=171335 written=14
97. 0.021 2,213.021 ↓ 8.0 8 1

Sort (cost=0.03..0.04 rows=1 width=112) (actual time=2,213.020..2,213.021 rows=8 loops=1)

  • Output: cf.exme_ctapac_id, cf.subtotal, cf.iva, cf.facturado
  • Sort Key: cf.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=380483 read=171335 written=14
98. 2,213.000 2,213.000 ↓ 8.0 8 1

CTE Scan on cargosfact cf (cost=0.00..0.02 rows=1 width=112) (actual time=2,212.977..2,213.000 rows=8 loops=1)

  • Output: cf.exme_ctapac_id, cf.subtotal, cf.iva, cf.facturado
  • Buffers: shared hit=380483 read=171335 written=14
99.          

CTE cargos1r

100. 0.016 79.108 ↓ 0.0 0 1

HashAggregate (cost=31,346.30..31,346.31 rows=1 width=48) (actual time=79.108..79.108 rows=0 loops=1)

  • Output: cf_1.exme_ctapac_id, (sum(cf_1.facturado) OVER (?))
  • Group Key: cf_1.exme_ctapac_id, sum(cf_1.facturado) OVER (?)
  • Buffers: shared hit=12574 read=7102
101.          

CTE cargosrem

102. 0.000 79.048 ↓ 0.0 0 1

Unique (cost=31,346.23..31,346.24 rows=1 width=45) (actual time=79.048..79.048 rows=0 loops=1)

  • Output: i_1.exme_ctapac_id, (COALESCE(i_1.grandtotal, '0'::numeric)), i_1.c_invoice_id
  • Buffers: shared hit=12574 read=7102
103.          

Initplan (forUnique)

104. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on params params_10 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: params_10.org_id
105. 0.011 0.011 ↑ 1.0 1 1

CTE Scan on params params_11 (cost=0.00..0.02 rows=1 width=32) (actual time=0.010..0.011 rows=1 loops=1)

  • Output: params_11.org_id
106. 0.005 0.005 ↑ 1.0 1 1

CTE Scan on params params_12 (cost=0.00..0.02 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=1)

  • Output: params_12.org_id
107. 0.020 79.031 ↓ 0.0 0 1

Sort (cost=31,346.17..31,346.17 rows=1 width=45) (actual time=79.031..79.031 rows=0 loops=1)

  • Output: i_1.exme_ctapac_id, (COALESCE(i_1.grandtotal, '0'::numeric)), i_1.c_invoice_id
  • Sort Key: i_1.exme_ctapac_id, (COALESCE(i_1.grandtotal, '0'::numeric)), i_1.c_invoice_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=12574 read=7102
108. 0.037 79.011 ↓ 0.0 0 1

Nested Loop Anti Join (cost=249.37..31,346.16 rows=1 width=45) (actual time=79.011..79.011 rows=0 loops=1)

  • Output: i_1.exme_ctapac_id, COALESCE(i_1.grandtotal, '0'::numeric), i_1.c_invoice_id
  • Buffers: shared hit=12574 read=7102
109. 0.039 78.834 ↓ 10.0 10 1

Nested Loop (cost=248.94..31,341.57 rows=1 width=25) (actual time=40.592..78.834 rows=10 loops=1)

  • Output: i_1.exme_ctapac_id, i_1.grandtotal, i_1.c_invoice_id, cpe_3.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=12545 read=7091
110. 0.049 78.681 ↓ 19.0 19 1

Nested Loop (cost=248.65..31,341.24 rows=1 width=31) (actual time=40.533..78.681 rows=19 loops=1)

  • Output: i_1.exme_ctapac_id, i_1.grandtotal, i_1.c_invoice_id, i_1.c_doctype_id, cpe_3.c_invoice_id
  • Buffers: shared hit=12490 read=7089
111. 0.124 78.416 ↑ 5.5 8 1

Nested Loop (cost=248.22..31,227.72 rows=44 width=12) (actual time=40.438..78.416 rows=8 loops=1)

  • Output: cpe_3.exme_ctapacext_id, cpe_3.c_invoice_id
  • Buffers: shared hit=12461 read=7075
112. 70.473 77.476 ↑ 1.4 48 1

Bitmap Heap Scan on public.exme_ctapac cp_4 (cost=247.79..30,660.38 rows=66 width=6) (actual time=25.880..77.476 rows=48 loops=1)

  • Output: cp_4.exme_ctapac_id, cp_4.ad_client_id, cp_4.ad_org_id, cp_4.isactive, cp_4.created, cp_4.createdby, cp_4.updated, cp_4.updatedby, cp_4.documentno, cp_4.docstatus, cp_4.docaction, cp_4.processing, cp_4.processed, cp_4.c_doctype_id, cp_4.c_doctypetarget_id, cp_4.description, cp_4.isapproved, cp_4.iscreditapproved, cp_4.isinvoiced, cp_4.isprinted, cp_4.dateordered, cp_4.dateprinted, cp_4.dateacct, cp_4.priorityrule, cp_4.grandtotal, cp_4.m_pricelist_id, cp_4.c_campaign_id, cp_4.c_project_id, cp_4.c_activity_id, cp_4.ad_user_id, cp_4.ad_orgtrx_id, cp_4.user1_id, cp_4.user2_id, cp_4.fechacancel, cp_4.exme_paciente_id, cp_4.exme_especialidad_id, cp_4.exme_motivocita_id, cp_4.estatus, cp_4.exme_medico_id, cp_4.ref_ctapac_id, cp_4.c_currency_id, cp_4.ad_printformat_id, cp_4.impcontrato, cp_4.impconsent, cp_4.impdatos, cp_4.impbrazalete, cp_4.exme_diagnostico_id, cp_4.exme_cama_id, cp_4.tipoarea, cp_4.fechacargodiario, cp_4.fechacierre, cp_4.exme_paqbase_version_id, cp_4.exme_ctapacext_id, cp_4.exme_estserv_id, cp_4.isuso, cp_4.isbloqueada, cp_4.isautorizada, cp_4.diagnostico_ingreso, cp_4.fechaalta, cp_4.actualizadoalta, cp_4.statusalta, cp_4.exme_camaing_id, cp_4.fechaprealta, cp_4.actualizadoprealta, cp_4.isfactespec, cp_4.ref_ctapacfam_id, cp_4.exme_descpreciofijo_id, cp_4.tiposangre, cp_4.exme_tipotrasplante_id, cp_4.exme_motivoegreso_id, cp_4.casosmedicos, cp_4.exme_estserving_id, cp_4.fechatraslado, cp_4.exme_procedencia_id, cp_4.isgenerated, cp_4.statuseleg, cp_4.instruccionalta, cp_4.nombrearchivo, cp_4.formatoarchivo, cp_4.archivo, cp_4.informealta, cp_4.exme_medico2_id, cp_4.exme_especialidad2_id, cp_4.exme_dischargestatus_id, cp_4.resstatus, cp_4.billingstatus, cp_4.exme_tipoprod_id, cp_4.drg, cp_4.exme_tipopaciente_id, cp_4.exme_arrivalmode_id, cp_4.exme_admittype_id, cp_4.exme_admitsource_id, cp_4.isnewborn, cp_4.exme_beneficiosh_id, cp_4.exme_estservprov_id, cp_4.billdate, cp_4.exme_area_id, cp_4.ref_unit_id, cp_4.encounterstatus, cp_4.exme_medicorefer_id, cp_4.exme_especialidadrefer_id, cp_4.exme_ctapacrefer_id, cp_4.isidentifier, cp_4.email, cp_4.requester, cp_4.fechaenv, cp_4.departuredate, cp_4.exme_pos_id, cp_4.exme_drg_id, cp_4.noinsurancecoverage, cp_4.nostatementage, cp_4.validonqueue, cp_4.exme_accompaniedby_id, cp_4.exme_transport_mode_id, cp_4.exme_discharged_via_id, cp_4.comments, cp_4.exme_institucion_id, cp_4.billingtype, cp_4.coded, cp_4.codingdate, cp_4.codedprof, cp_4.codingdateprof, cp_4.institutionalstatus, cp_4.institutionalstep, cp_4.isvalid, cp_4.nombre_pac, cp_4.mrn, cp_4.processingpaq, cp_4.processingpaq2, cp_4.isclosed, cp_4.exme_eventmerge_id, cp_4.fallrisk, cp_4.triage, cp_4.apollo_policy, cp_4.apollo_claim
  • Recheck Cond: (cp_4.ad_org_id = $37)
  • Filter: ((COALESCE(cp_4.fechaalta, cp_4.fechacierre) IS NULL) AND (cp_4.fechacancel IS NULL) AND (cp_4.isactive = 'Y'::bpchar) AND ((cp_4.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 26064
  • Heap Blocks: exact=19258
  • Buffers: shared hit=12335 read=6997
113. 7.003 7.003 ↓ 2.0 26,112 1

Bitmap Index Scan on ender_exme_ctapac_active_client_org (cost=0.00..247.78 rows=13,247 width=0) (actual time=7.003..7.003 rows=26,112 loops=1)

  • Index Cond: (cp_4.ad_org_id = $37)
  • Buffers: shared read=74
114. 0.816 0.816 ↓ 0.0 0 48

Index Scan using exmectapacext_exmectapacid on public.exme_ctapacext cpe_3 (cost=0.43..8.59 rows=1 width=18) (actual time=0.017..0.017 rows=0 loops=48)

  • Output: cpe_3.exme_ctapacext_id, cpe_3.ad_client_id, cpe_3.ad_org_id, cpe_3.isactive, cpe_3.created, cpe_3.createdby, cpe_3.updated, cpe_3.updatedby, cpe_3.documentno, cpe_3.docstatus, cpe_3.docaction, cpe_3.processing, cpe_3.processed, cpe_3.c_doctype_id, cpe_3.c_doctypetarget_id, cpe_3.description, cpe_3.isapproved, cpe_3.isprinted, cpe_3.dateordered, cpe_3.dateacct, cpe_3.c_bpartner_id, cpe_3.c_bpartner_location_id, cpe_3.c_charge_id, cpe_3.chargeamt, cpe_3.totallines, cpe_3.grandtotal, cpe_3.ad_user_id, cpe_3.ad_orgtrx_id, cpe_3.ref_ctapacext_id, cpe_3.desctoglobal, cpe_3.coaseguro, cpe_3.deducible, cpe_3.c_invoice_id, cpe_3.exme_ctapac_id, cpe_3.rfc, cpe_3.extensionno, cpe_3.iscoasegpercent, cpe_3.isdeducincoaseg, cpe_3.desctoglobalamt, cpe_3.observacion, cpe_3.c_location_id, cpe_3.anticipo, cpe_3.coaseguromed, cpe_3.copago, cpe_3.taxamt, cpe_3.coaseguroamt, cpe_3.deducibleamt, cpe_3.coaseguromedamt, cpe_3.copagoamt, cpe_3.isdiscpercent, cpe_3.isdeducpercent, cpe_3.iscoasmedpercent, cpe_3.iscoppercent, cpe_3.conftype, cpe_3.institutionalstatus, cpe_3.institutionalstep, cpe_3.professionalstatus, cpe_3.professionalstep, cpe_3.chargestatus, cpe_3.discounttaxamt, cpe_3.isorderfaclinecategory, cpe_3.coasegurotax, cpe_3.deducibletax, cpe_3.coaseguromedtax, cpe_3.copagotax, cpe_3.emprelationship
  • Index Cond: (cpe_3.exme_ctapac_id = cp_4.exme_ctapac_id)
  • Filter: (cpe_3.c_invoice_id IS NOT NULL)
  • Rows Removed by Filter: 1
  • Buffers: shared hit=126 read=78
115. 0.216 0.216 ↓ 2.0 2 8

Index Scan using bi_c_invoice_exme_ctapacext_id on public.c_invoice i_1 (cost=0.43..2.57 rows=1 width=32) (actual time=0.023..0.027 rows=2 loops=8)

  • Output: i_1.c_invoice_id, i_1.ad_client_id, i_1.ad_org_id, i_1.isactive, i_1.created, i_1.createdby, i_1.updated, i_1.updatedby, i_1.issotrx, i_1.documentno, i_1.docstatus, i_1.docaction, i_1.processing, i_1.processed, i_1.posted, i_1.c_doctype_id, i_1.c_doctypetarget_id, i_1.c_order_id, i_1.description, i_1.isapproved, i_1.istransferred, i_1.isprinted, i_1.salesrep_id, i_1.dateinvoiced, i_1.dateprinted, i_1.dateacct, i_1.c_bpartner_id, i_1.c_bpartner_location_id, i_1.poreference, i_1.isdiscountprinted, i_1.dateordered, i_1.c_currency_id, i_1.paymentrule, i_1.c_paymentterm_id, i_1.c_charge_id, i_1.chargeamt, i_1.totallines, i_1.grandtotal, i_1.m_pricelist_id, i_1.istaxincluded, i_1.c_campaign_id, i_1.c_project_id, i_1.c_activity_id, i_1.ispaid, i_1.c_payment_id, i_1.c_cashline_id, i_1.createfrom, i_1.generateto, i_1.sendemail, i_1.ad_user_id, i_1.copyfrom, i_1.isselfservice, i_1.ad_orgtrx_id, i_1.user1_id, i_1.user2_id, i_1.c_conversiontype_id, i_1.ispayschedulevalid, i_1.ref_invoice_id, i_1.isindispute, i_1.exme_ctapacext_id, i_1.descfromaseg, i_1.precfromaseg, i_1.documentnoext, i_1.afecta_caja, i_1.c_cashbook_id, i_1.discountporcent, i_1.discountamt, i_1.address1, i_1.address2, i_1.city, i_1.postal, i_1.c_country_id, i_1.c_region_id, i_1.address3, i_1.exme_paciente_id, i_1.exme_medico_id, i_1.nombre_medico, i_1.nombre_paciente, i_1.exme_estserv_id, i_1.c_cash_id, i_1.canceledby, i_1.motivocancel, i_1.exme_motivocancel_id, i_1.isprintedpre, i_1.updatedbycancel, i_1.numext, i_1.numin, i_1.sexo, i_1.fechanac, i_1.invoicephone, i_1.exme_towncouncil_id, i_1.tipooperacion, i_1.observation, i_1.dunninggrace, i_1.m_rma_id, i_1.c_dunninglevel_id, i_1.invoicecollectiontype, i_1.reversal_id, i_1.verpoliza, i_1.isgenerated, i_1.globaldiscount, i_1.sello, i_1.cadena, i_1.exme_ctapac_id, i_1.conftype, i_1.multiple_id, i_1.ismultiple, i_1.partner, i_1.uuid, i_1.estserv, i_1.prepayment, i_1.backoffice, i_1.discounttaxamt, i_1.taxamt, i_1.exme_claimpayment_id, i_1.coaseguro, i_1.deducible, i_1.coaseguromed, i_1.copago, i_1.coaseguroamt, i_1.deducibleamt, i_1.coaseguromedamt, i_1.copagoamt, i_1.ref_invoice_sales_id, i_1.isinvoiced, i_1.isorderfaclinecategory, i_1.trxtype, i_1.rebate, i_1.sortby, i_1.addenda, i_1.sellosat, i_1.certificadosat, i_1.nocertificado, i_1.certificado, i_1.rate, i_1.m_inout_id, i_1.generatedfrom, i_1.typeacct, i_1.detailpayment, i_1.c_cash_cancel_id, i_1.datecanceled, i_1.exme_areacaja_id, i_1.accountno, i_1.post, i_1.statusuuid, i_1.canceldescription, i_1.versionno, i_1.emprelationship, i_1.perception, i_1.comp_ditto, i_1.perceptioniva, i_1.afip, i_1.date_comp, i_1.typefac_ditto
  • Index Cond: (i_1.exme_ctapacext_id = cpe_3.exme_ctapacext_id)
  • Filter: ((i_1.multiple_id IS NULL) AND (i_1.c_doctype_id > '0'::numeric) AND (i_1.docstatus <> 'VO'::bpchar) AND (i_1.isactive = 'Y'::bpchar) AND (i_1.issotrx = 'Y'::bpchar) AND (i_1.ad_org_id = $38))
  • Buffers: shared hit=29 read=14
116. 0.114 0.114 ↑ 1.0 1 19

Index Scan using c_doctype_c_doctype_id on public.c_doctype dt_2 (cost=0.29..0.33 rows=1 width=6) (actual time=0.006..0.006 rows=1 loops=19)

  • Output: dt_2.c_doctype_id, dt_2.ad_client_id, dt_2.ad_org_id, dt_2.isactive, dt_2.created, dt_2.createdby, dt_2.updated, dt_2.updatedby, dt_2.name, dt_2.printname, dt_2.description, dt_2.docbasetype, dt_2.issotrx, dt_2.docsubtypeso, dt_2.hasproforma, dt_2.c_doctypeproforma_id, dt_2.c_doctypeshipment_id, dt_2.c_doctypeinvoice_id, dt_2.isdocnocontrolled, dt_2.docnosequence_id, dt_2.gl_category_id, dt_2.hascharges, dt_2.documentnote, dt_2.isdefault, dt_2.documentcopies, dt_2.ad_printformat_id, dt_2.isdefaultcounterdoc, dt_2.isshipconfirm, dt_2.ispickqaconfirm, dt_2.isintransit, dt_2.issplitwhendifference, dt_2.c_doctypedifference_id, dt_2.iscreatecounter, dt_2.isindexed, dt_2.definitesequence_id, dt_2.isoverwriteseqoncomplete, dt_2.isoverwritedateoncomplete, dt_2.exme_typevouchercode_id, dt_2.exme_relationtypecode_id, dt_2.type
  • Index Cond: (dt_2.c_doctype_id = i_1.c_doctype_id)
  • Filter: ((dt_2.docsubtypeso IS NULL) AND (dt_2.docbasetype = 'ARI'::bpchar))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=55 read=2
117. 0.140 0.140 ↑ 1.0 1 10

Index Scan using c_invoice_ref_invoice_sales_id on public.c_invoice (cost=0.43..2.51 rows=1 width=6) (actual time=0.014..0.014 rows=1 loops=10)

  • Output: c_invoice.c_invoice_id, c_invoice.ad_client_id, c_invoice.ad_org_id, c_invoice.isactive, c_invoice.created, c_invoice.createdby, c_invoice.updated, c_invoice.updatedby, c_invoice.issotrx, c_invoice.documentno, c_invoice.docstatus, c_invoice.docaction, c_invoice.processing, c_invoice.processed, c_invoice.posted, c_invoice.c_doctype_id, c_invoice.c_doctypetarget_id, c_invoice.c_order_id, c_invoice.description, c_invoice.isapproved, c_invoice.istransferred, c_invoice.isprinted, c_invoice.salesrep_id, c_invoice.dateinvoiced, c_invoice.dateprinted, c_invoice.dateacct, c_invoice.c_bpartner_id, c_invoice.c_bpartner_location_id, c_invoice.poreference, c_invoice.isdiscountprinted, c_invoice.dateordered, c_invoice.c_currency_id, c_invoice.paymentrule, c_invoice.c_paymentterm_id, c_invoice.c_charge_id, c_invoice.chargeamt, c_invoice.totallines, c_invoice.grandtotal, c_invoice.m_pricelist_id, c_invoice.istaxincluded, c_invoice.c_campaign_id, c_invoice.c_project_id, c_invoice.c_activity_id, c_invoice.ispaid, c_invoice.c_payment_id, c_invoice.c_cashline_id, c_invoice.createfrom, c_invoice.generateto, c_invoice.sendemail, c_invoice.ad_user_id, c_invoice.copyfrom, c_invoice.isselfservice, c_invoice.ad_orgtrx_id, c_invoice.user1_id, c_invoice.user2_id, c_invoice.c_conversiontype_id, c_invoice.ispayschedulevalid, c_invoice.ref_invoice_id, c_invoice.isindispute, c_invoice.exme_ctapacext_id, c_invoice.descfromaseg, c_invoice.precfromaseg, c_invoice.documentnoext, c_invoice.afecta_caja, c_invoice.c_cashbook_id, c_invoice.discountporcent, c_invoice.discountamt, c_invoice.address1, c_invoice.address2, c_invoice.city, c_invoice.postal, c_invoice.c_country_id, c_invoice.c_region_id, c_invoice.address3, c_invoice.exme_paciente_id, c_invoice.exme_medico_id, c_invoice.nombre_medico, c_invoice.nombre_paciente, c_invoice.exme_estserv_id, c_invoice.c_cash_id, c_invoice.canceledby, c_invoice.motivocancel, c_invoice.exme_motivocancel_id, c_invoice.isprintedpre, c_invoice.updatedbycancel, c_invoice.numext, c_invoice.numin, c_invoice.sexo, c_invoice.fechanac, c_invoice.invoicephone, c_invoice.exme_towncouncil_id, c_invoice.tipooperacion, c_invoice.observation, c_invoice.dunninggrace, c_invoice.m_rma_id, c_invoice.c_dunninglevel_id, c_invoice.invoicecollectiontype, c_invoice.reversal_id, c_invoice.verpoliza, c_invoice.isgenerated, c_invoice.globaldiscount, c_invoice.sello, c_invoice.cadena, c_invoice.exme_ctapac_id, c_invoice.conftype, c_invoice.multiple_id, c_invoice.ismultiple, c_invoice.partner, c_invoice.uuid, c_invoice.estserv, c_invoice.prepayment, c_invoice.backoffice, c_invoice.discounttaxamt, c_invoice.taxamt, c_invoice.exme_claimpayment_id, c_invoice.coaseguro, c_invoice.deducible, c_invoice.coaseguromed, c_invoice.copago, c_invoice.coaseguroamt, c_invoice.deducibleamt, c_invoice.coaseguromedamt, c_invoice.copagoamt, c_invoice.ref_invoice_sales_id, c_invoice.isinvoiced, c_invoice.isorderfaclinecategory, c_invoice.trxtype, c_invoice.rebate, c_invoice.sortby, c_invoice.addenda, c_invoice.sellosat, c_invoice.certificadosat, c_invoice.nocertificado, c_invoice.certificado, c_invoice.rate, c_invoice.m_inout_id, c_invoice.generatedfrom, c_invoice.typeacct, c_invoice.detailpayment, c_invoice.c_cash_cancel_id, c_invoice.datecanceled, c_invoice.exme_areacaja_id, c_invoice.accountno, c_invoice.post, c_invoice.statusuuid, c_invoice.canceldescription, c_invoice.versionno, c_invoice.emprelationship, c_invoice.perception, c_invoice.comp_ditto, c_invoice.perceptioniva, c_invoice.afip, c_invoice.date_comp, c_invoice.typefac_ditto
  • Index Cond: ((cpe_3.c_invoice_id = c_invoice.ref_invoice_sales_id) AND (c_invoice.ref_invoice_sales_id IS NOT NULL))
  • Filter: ((c_invoice.ad_org_id = $39) AND (c_invoice.isactive = 'Y'::bpchar) AND (c_invoice.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
  • Buffers: shared hit=29 read=11
118. 0.013 79.092 ↓ 0.0 0 1

WindowAgg (cost=0.03..0.05 rows=1 width=48) (actual time=79.092..79.092 rows=0 loops=1)

  • Output: cf_1.exme_ctapac_id, sum(cf_1.facturado) OVER (?)
  • Buffers: shared hit=12574 read=7102
119. 0.021 79.079 ↓ 0.0 0 1

Sort (cost=0.03..0.04 rows=1 width=48) (actual time=79.079..79.079 rows=0 loops=1)

  • Output: cf_1.exme_ctapac_id, cf_1.facturado
  • Sort Key: cf_1.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=12574 read=7102
120. 79.058 79.058 ↓ 0.0 0 1

CTE Scan on cargosrem cf_1 (cost=0.00..0.02 rows=1 width=48) (actual time=79.058..79.058 rows=0 loops=1)

  • Output: cf_1.exme_ctapac_id, cf_1.facturado
  • Buffers: shared hit=12574 read=7102
121.          

CTE cargos1r_fg

122. 0.027 1,598.113 ↓ 0.0 0 1

HashAggregate (cost=24,251.98..24,251.99 rows=1 width=48) (actual time=1,598.112..1,598.113 rows=0 loops=1)

  • Output: cf_2.exme_ctapac_id, (sum(cf_2.facturado) OVER (?))
  • Group Key: cf_2.exme_ctapac_id, sum(cf_2.facturado) OVER (?)
  • Buffers: shared hit=9243 read=87813
123.          

CTE cargosrem

124. 0.018 1,598.026 ↓ 0.0 0 1

Unique (cost=24,251.91..24,251.92 rows=1 width=45) (actual time=1,598.026..1,598.026 rows=0 loops=1)

  • Output: i_2.exme_ctapac_id, (COALESCE(i_2.grandtotal, '0'::numeric)), i_2.c_invoice_id
  • Buffers: shared hit=9243 read=87813
125.          

Initplan (forUnique)

126. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_13 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_13.org_id
127. 0.009 0.009 ↑ 1.0 1 1

CTE Scan on params params_14 (cost=0.00..0.02 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=1)

  • Output: params_14.org_id
128. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_15 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_15.org_id
129. 0.016 1,597.999 ↓ 0.0 0 1

Sort (cost=24,251.85..24,251.85 rows=1 width=45) (actual time=1,597.999..1,597.999 rows=0 loops=1)

  • Output: i_2.exme_ctapac_id, (COALESCE(i_2.grandtotal, '0'::numeric)), i_2.c_invoice_id
  • Sort Key: i_2.exme_ctapac_id, (COALESCE(i_2.grandtotal, '0'::numeric)), i_2.c_invoice_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=9243 read=87813
130. 0.014 1,597.983 ↓ 0.0 0 1

Nested Loop Anti Join (cost=7,767.44..24,251.84 rows=1 width=45) (actual time=1,597.983..1,597.983 rows=0 loops=1)

  • Output: i_2.exme_ctapac_id, COALESCE(i_2.grandtotal, '0'::numeric), i_2.c_invoice_id
  • Buffers: shared hit=9243 read=87813
131. 0.025 1,597.969 ↓ 0.0 0 1

Nested Loop Semi Join (cost=7,767.01..24,247.26 rows=1 width=25) (actual time=1,597.969..1,597.969 rows=0 loops=1)

  • Output: i_2.exme_ctapac_id, i_2.grandtotal, i_2.c_invoice_id, cpe_4.c_invoice_id
  • Buffers: shared hit=9243 read=87813
132. 0.028 1,597.944 ↓ 0.0 0 1

Nested Loop (cost=7,766.16..24,240.02 rows=1 width=25) (actual time=1,597.944..1,597.944 rows=0 loops=1)

  • Output: i_2.exme_ctapac_id, i_2.grandtotal, i_2.c_invoice_id, cpe_4.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=9243 read=87813
133. 43.019 1,597.885 ↑ 21.0 1 1

Nested Loop (cost=7,765.73..24,223.33 rows=21 width=31) (actual time=297.250..1,597.885 rows=1 loops=1)

  • Output: i_2.exme_ctapac_id, i_2.grandtotal, i_2.c_invoice_id, cpe_4.exme_ctapac_id, cpe_4.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=9239 read=87813
134. 47.822 1,554.866 ↓ 631.8 62,553 1

Hash Join (cost=7,765.31..23,518.21 rows=99 width=26) (actual time=270.712..1,554.866 rows=62,553 loops=1)

  • Output: i_2.exme_ctapac_id, i_2.grandtotal, i_2.c_invoice_id, i_2.exme_ctapacext_id
  • Inner Unique: true
  • Hash Cond: (i_2.c_doctype_id = dt_3.c_doctype_id)
  • Buffers: shared hit=9237 read=87811
135. 1,240.820 1,506.726 ↓ 15.9 62,553 1

Bitmap Heap Scan on public.c_invoice i_2 (cost=7,532.49..23,275.04 rows=3,941 width=32) (actual time=270.346..1,506.726 rows=62,553 loops=1)

  • Output: i_2.c_invoice_id, i_2.ad_client_id, i_2.ad_org_id, i_2.isactive, i_2.created, i_2.createdby, i_2.updated, i_2.updatedby, i_2.issotrx, i_2.documentno, i_2.docstatus, i_2.docaction, i_2.processing, i_2.processed, i_2.posted, i_2.c_doctype_id, i_2.c_doctypetarget_id, i_2.c_order_id, i_2.description, i_2.isapproved, i_2.istransferred, i_2.isprinted, i_2.salesrep_id, i_2.dateinvoiced, i_2.dateprinted, i_2.dateacct, i_2.c_bpartner_id, i_2.c_bpartner_location_id, i_2.poreference, i_2.isdiscountprinted, i_2.dateordered, i_2.c_currency_id, i_2.paymentrule, i_2.c_paymentterm_id, i_2.c_charge_id, i_2.chargeamt, i_2.totallines, i_2.grandtotal, i_2.m_pricelist_id, i_2.istaxincluded, i_2.c_campaign_id, i_2.c_project_id, i_2.c_activity_id, i_2.ispaid, i_2.c_payment_id, i_2.c_cashline_id, i_2.createfrom, i_2.generateto, i_2.sendemail, i_2.ad_user_id, i_2.copyfrom, i_2.isselfservice, i_2.ad_orgtrx_id, i_2.user1_id, i_2.user2_id, i_2.c_conversiontype_id, i_2.ispayschedulevalid, i_2.ref_invoice_id, i_2.isindispute, i_2.exme_ctapacext_id, i_2.descfromaseg, i_2.precfromaseg, i_2.documentnoext, i_2.afecta_caja, i_2.c_cashbook_id, i_2.discountporcent, i_2.discountamt, i_2.address1, i_2.address2, i_2.city, i_2.postal, i_2.c_country_id, i_2.c_region_id, i_2.address3, i_2.exme_paciente_id, i_2.exme_medico_id, i_2.nombre_medico, i_2.nombre_paciente, i_2.exme_estserv_id, i_2.c_cash_id, i_2.canceledby, i_2.motivocancel, i_2.exme_motivocancel_id, i_2.isprintedpre, i_2.updatedbycancel, i_2.numext, i_2.numin, i_2.sexo, i_2.fechanac, i_2.invoicephone, i_2.exme_towncouncil_id, i_2.tipooperacion, i_2.observation, i_2.dunninggrace, i_2.m_rma_id, i_2.c_dunninglevel_id, i_2.invoicecollectiontype, i_2.reversal_id, i_2.verpoliza, i_2.isgenerated, i_2.globaldiscount, i_2.sello, i_2.cadena, i_2.exme_ctapac_id, i_2.conftype, i_2.multiple_id, i_2.ismultiple, i_2.partner, i_2.uuid, i_2.estserv, i_2.prepayment, i_2.backoffice, i_2.discounttaxamt, i_2.taxamt, i_2.exme_claimpayment_id, i_2.coaseguro, i_2.deducible, i_2.coaseguromed, i_2.copago, i_2.coaseguroamt, i_2.deducibleamt, i_2.coaseguromedamt, i_2.copagoamt, i_2.ref_invoice_sales_id, i_2.isinvoiced, i_2.isorderfaclinecategory, i_2.trxtype, i_2.rebate, i_2.sortby, i_2.addenda, i_2.sellosat, i_2.certificadosat, i_2.nocertificado, i_2.certificado, i_2.rate, i_2.m_inout_id, i_2.generatedfrom, i_2.typeacct, i_2.detailpayment, i_2.c_cash_cancel_id, i_2.datecanceled, i_2.exme_areacaja_id, i_2.accountno, i_2.post, i_2.statusuuid, i_2.canceldescription, i_2.versionno, i_2.emprelationship, i_2.perception, i_2.comp_ditto, i_2.perceptioniva, i_2.afip, i_2.date_comp, i_2.typefac_ditto
  • Recheck Cond: ((i_2.ad_org_id = $47) AND (i_2.c_doctype_id > '0'::numeric) AND (i_2.issotrx = 'Y'::bpchar) AND (i_2.multiple_id IS NOT NULL))
  • Rows Removed by Index Recheck: 663734
  • Filter: ((i_2.docstatus <> ALL ('{VO,RE}'::bpchar[])) AND (i_2.isactive = 'Y'::bpchar))
  • Heap Blocks: exact=13106 lossy=79683
  • Buffers: shared hit=9207 read=87808
136. 17.427 265.906 ↓ 0.0 0 1

BitmapAnd (cost=7,532.49..7,532.49 rows=4,312 width=0) (actual time=265.906..265.906 rows=0 loops=1)

  • Buffers: shared read=4226
137. 178.312 178.312 ↓ 7.4 315,748 1

Bitmap Index Scan on docsearch_c_invoice (cost=0.00..2,676.40 rows=42,551 width=0) (actual time=178.312..178.312 rows=315,748 loops=1)

  • Index Cond: ((i_2.ad_org_id = $47) AND (i_2.c_doctype_id > '0'::numeric) AND (i_2.issotrx = 'Y'::bpchar))
  • Buffers: shared read=3517
138. 70.167 70.167 ↑ 1.0 258,538 1

Bitmap Index Scan on c_invoice_multiple_id (cost=0.00..4,853.86 rows=262,591 width=0) (actual time=70.167..70.167 rows=258,538 loops=1)

  • Index Cond: (i_2.multiple_id IS NOT NULL)
  • Buffers: shared read=709
139. 0.069 0.318 ↑ 1.4 170 1

Hash (cost=229.89..229.89 rows=234 width=6) (actual time=0.318..0.318 rows=170 loops=1)

  • Output: dt_3.c_doctype_id
  • Buckets: 1024 Batches: 1 Memory Usage: 15kB
  • Buffers: shared hit=30 read=3
140. 0.181 0.249 ↑ 1.4 170 1

Bitmap Heap Scan on public.c_doctype dt_3 (cost=10.88..229.89 rows=234 width=6) (actual time=0.096..0.249 rows=170 loops=1)

  • Output: dt_3.c_doctype_id
  • Recheck Cond: (dt_3.docbasetype = 'ARI'::bpchar)
  • Filter: (dt_3.docsubtypeso IS NULL)
  • Rows Removed by Filter: 168
  • Heap Blocks: exact=30
  • Buffers: shared hit=30 read=3
141. 0.068 0.068 ↑ 1.0 338 1

Bitmap Index Scan on c_doctype_idx (cost=0.00..10.82 rows=338 width=0) (actual time=0.068..0.068 rows=338 loops=1)

  • Index Cond: (dt_3.docbasetype = 'ARI'::bpchar)
  • Buffers: shared read=3
142. 0.000 0.000 ↓ 0.0 0 62,553

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe_4 (cost=0.43..7.12 rows=1 width=18) (actual time=0.000..0.000 rows=0 loops=62,553)

  • Output: cpe_4.exme_ctapacext_id, cpe_4.ad_client_id, cpe_4.ad_org_id, cpe_4.isactive, cpe_4.created, cpe_4.createdby, cpe_4.updated, cpe_4.updatedby, cpe_4.documentno, cpe_4.docstatus, cpe_4.docaction, cpe_4.processing, cpe_4.processed, cpe_4.c_doctype_id, cpe_4.c_doctypetarget_id, cpe_4.description, cpe_4.isapproved, cpe_4.isprinted, cpe_4.dateordered, cpe_4.dateacct, cpe_4.c_bpartner_id, cpe_4.c_bpartner_location_id, cpe_4.c_charge_id, cpe_4.chargeamt, cpe_4.totallines, cpe_4.grandtotal, cpe_4.ad_user_id, cpe_4.ad_orgtrx_id, cpe_4.ref_ctapacext_id, cpe_4.desctoglobal, cpe_4.coaseguro, cpe_4.deducible, cpe_4.c_invoice_id, cpe_4.exme_ctapac_id, cpe_4.rfc, cpe_4.extensionno, cpe_4.iscoasegpercent, cpe_4.isdeducincoaseg, cpe_4.desctoglobalamt, cpe_4.observacion, cpe_4.c_location_id, cpe_4.anticipo, cpe_4.coaseguromed, cpe_4.copago, cpe_4.taxamt, cpe_4.coaseguroamt, cpe_4.deducibleamt, cpe_4.coaseguromedamt, cpe_4.copagoamt, cpe_4.isdiscpercent, cpe_4.isdeducpercent, cpe_4.iscoasmedpercent, cpe_4.iscoppercent, cpe_4.conftype, cpe_4.institutionalstatus, cpe_4.institutionalstep, cpe_4.professionalstatus, cpe_4.professionalstep, cpe_4.chargestatus, cpe_4.discounttaxamt, cpe_4.isorderfaclinecategory, cpe_4.coasegurotax, cpe_4.deducibletax, cpe_4.coaseguromedtax, cpe_4.copagotax, cpe_4.emprelationship
  • Index Cond: (cpe_4.exme_ctapacext_id = i_2.exme_ctapacext_id)
  • Filter: (cpe_4.c_invoice_id IS NOT NULL)
  • Buffers: shared hit=2 read=2
143. 0.031 0.031 ↓ 0.0 0 1

Index Scan using exme_ctapac_pkey on public.exme_ctapac cp_5 (cost=0.42..0.79 rows=1 width=6) (actual time=0.031..0.031 rows=0 loops=1)

  • Output: cp_5.exme_ctapac_id, cp_5.ad_client_id, cp_5.ad_org_id, cp_5.isactive, cp_5.created, cp_5.createdby, cp_5.updated, cp_5.updatedby, cp_5.documentno, cp_5.docstatus, cp_5.docaction, cp_5.processing, cp_5.processed, cp_5.c_doctype_id, cp_5.c_doctypetarget_id, cp_5.description, cp_5.isapproved, cp_5.iscreditapproved, cp_5.isinvoiced, cp_5.isprinted, cp_5.dateordered, cp_5.dateprinted, cp_5.dateacct, cp_5.priorityrule, cp_5.grandtotal, cp_5.m_pricelist_id, cp_5.c_campaign_id, cp_5.c_project_id, cp_5.c_activity_id, cp_5.ad_user_id, cp_5.ad_orgtrx_id, cp_5.user1_id, cp_5.user2_id, cp_5.fechacancel, cp_5.exme_paciente_id, cp_5.exme_especialidad_id, cp_5.exme_motivocita_id, cp_5.estatus, cp_5.exme_medico_id, cp_5.ref_ctapac_id, cp_5.c_currency_id, cp_5.ad_printformat_id, cp_5.impcontrato, cp_5.impconsent, cp_5.impdatos, cp_5.impbrazalete, cp_5.exme_diagnostico_id, cp_5.exme_cama_id, cp_5.tipoarea, cp_5.fechacargodiario, cp_5.fechacierre, cp_5.exme_paqbase_version_id, cp_5.exme_ctapacext_id, cp_5.exme_estserv_id, cp_5.isuso, cp_5.isbloqueada, cp_5.isautorizada, cp_5.diagnostico_ingreso, cp_5.fechaalta, cp_5.actualizadoalta, cp_5.statusalta, cp_5.exme_camaing_id, cp_5.fechaprealta, cp_5.actualizadoprealta, cp_5.isfactespec, cp_5.ref_ctapacfam_id, cp_5.exme_descpreciofijo_id, cp_5.tiposangre, cp_5.exme_tipotrasplante_id, cp_5.exme_motivoegreso_id, cp_5.casosmedicos, cp_5.exme_estserving_id, cp_5.fechatraslado, cp_5.exme_procedencia_id, cp_5.isgenerated, cp_5.statuseleg, cp_5.instruccionalta, cp_5.nombrearchivo, cp_5.formatoarchivo, cp_5.archivo, cp_5.informealta, cp_5.exme_medico2_id, cp_5.exme_especialidad2_id, cp_5.exme_dischargestatus_id, cp_5.resstatus, cp_5.billingstatus, cp_5.exme_tipoprod_id, cp_5.drg, cp_5.exme_tipopaciente_id, cp_5.exme_arrivalmode_id, cp_5.exme_admittype_id, cp_5.exme_admitsource_id, cp_5.isnewborn, cp_5.exme_beneficiosh_id, cp_5.exme_estservprov_id, cp_5.billdate, cp_5.exme_area_id, cp_5.ref_unit_id, cp_5.encounterstatus, cp_5.exme_medicorefer_id, cp_5.exme_especialidadrefer_id, cp_5.exme_ctapacrefer_id, cp_5.isidentifier, cp_5.email, cp_5.requester, cp_5.fechaenv, cp_5.departuredate, cp_5.exme_pos_id, cp_5.exme_drg_id, cp_5.noinsurancecoverage, cp_5.nostatementage, cp_5.validonqueue, cp_5.exme_accompaniedby_id, cp_5.exme_transport_mode_id, cp_5.exme_discharged_via_id, cp_5.comments, cp_5.exme_institucion_id, cp_5.billingtype, cp_5.coded, cp_5.codingdate, cp_5.codedprof, cp_5.codingdateprof, cp_5.institutionalstatus, cp_5.institutionalstep, cp_5.isvalid, cp_5.nombre_pac, cp_5.mrn, cp_5.processingpaq, cp_5.processingpaq2, cp_5.isclosed, cp_5.exme_eventmerge_id, cp_5.fallrisk, cp_5.triage, cp_5.apollo_policy, cp_5.apollo_claim
  • Index Cond: (cp_5.exme_ctapac_id = cpe_4.exme_ctapac_id)
  • Filter: ((COALESCE(cp_5.fechaalta, cp_5.fechacierre) IS NULL) AND (cp_5.fechacancel IS NULL) AND (cp_5.ad_org_id = $46) AND (cp_5.isactive = 'Y'::bpchar) AND ((cp_5.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=4
144. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.85..7.23 rows=1 width=6) (never executed)

  • Output: g.c_invoice_id
  • Inner Unique: true
145. 0.000 0.000 ↓ 0.0 0

Index Only Scan using invoiceglobal_key on public.exme_globalinvoicedetail g (cost=0.42..3.73 rows=1 width=13) (never executed)

  • Output: g.c_invoice_id, g.ref_invoice_id
  • Index Cond: (g.c_invoice_id = i_2.c_invoice_id)
  • Heap Fetches: 0
146. 0.000 0.000 ↓ 0.0 0

Index Scan using c_invoice_pkey on public.c_invoice fg (cost=0.43..3.50 rows=1 width=6) (never executed)

  • Output: fg.c_invoice_id, fg.ad_client_id, fg.ad_org_id, fg.isactive, fg.created, fg.createdby, fg.updated, fg.updatedby, fg.issotrx, fg.documentno, fg.docstatus, fg.docaction, fg.processing, fg.processed, fg.posted, fg.c_doctype_id, fg.c_doctypetarget_id, fg.c_order_id, fg.description, fg.isapproved, fg.istransferred, fg.isprinted, fg.salesrep_id, fg.dateinvoiced, fg.dateprinted, fg.dateacct, fg.c_bpartner_id, fg.c_bpartner_location_id, fg.poreference, fg.isdiscountprinted, fg.dateordered, fg.c_currency_id, fg.paymentrule, fg.c_paymentterm_id, fg.c_charge_id, fg.chargeamt, fg.totallines, fg.grandtotal, fg.m_pricelist_id, fg.istaxincluded, fg.c_campaign_id, fg.c_project_id, fg.c_activity_id, fg.ispaid, fg.c_payment_id, fg.c_cashline_id, fg.createfrom, fg.generateto, fg.sendemail, fg.ad_user_id, fg.copyfrom, fg.isselfservice, fg.ad_orgtrx_id, fg.user1_id, fg.user2_id, fg.c_conversiontype_id, fg.ispayschedulevalid, fg.ref_invoice_id, fg.isindispute, fg.exme_ctapacext_id, fg.descfromaseg, fg.precfromaseg, fg.documentnoext, fg.afecta_caja, fg.c_cashbook_id, fg.discountporcent, fg.discountamt, fg.address1, fg.address2, fg.city, fg.postal, fg.c_country_id, fg.c_region_id, fg.address3, fg.exme_paciente_id, fg.exme_medico_id, fg.nombre_medico, fg.nombre_paciente, fg.exme_estserv_id, fg.c_cash_id, fg.canceledby, fg.motivocancel, fg.exme_motivocancel_id, fg.isprintedpre, fg.updatedbycancel, fg.numext, fg.numin, fg.sexo, fg.fechanac, fg.invoicephone, fg.exme_towncouncil_id, fg.tipooperacion, fg.observation, fg.dunninggrace, fg.m_rma_id, fg.c_dunninglevel_id, fg.invoicecollectiontype, fg.reversal_id, fg.verpoliza, fg.isgenerated, fg.globaldiscount, fg.sello, fg.cadena, fg.exme_ctapac_id, fg.conftype, fg.multiple_id, fg.ismultiple, fg.partner, fg.uuid, fg.estserv, fg.prepayment, fg.backoffice, fg.discounttaxamt, fg.taxamt, fg.exme_claimpayment_id, fg.coaseguro, fg.deducible, fg.coaseguromed, fg.copago, fg.coaseguroamt, fg.deducibleamt, fg.coaseguromedamt, fg.copagoamt, fg.ref_invoice_sales_id, fg.isinvoiced, fg.isorderfaclinecategory, fg.trxtype, fg.rebate, fg.sortby, fg.addenda, fg.sellosat, fg.certificadosat, fg.nocertificado, fg.certificado, fg.rate, fg.m_inout_id, fg.generatedfrom, fg.typeacct, fg.detailpayment, fg.c_cash_cancel_id, fg.datecanceled, fg.exme_areacaja_id, fg.accountno, fg.post, fg.statusuuid, fg.canceldescription, fg.versionno, fg.emprelationship, fg.perception, fg.comp_ditto, fg.perceptioniva, fg.afip, fg.date_comp, fg.typefac_ditto
  • Index Cond: (fg.c_invoice_id = g.ref_invoice_id)
  • Filter: (fg.docstatus <> ALL ('{VO,RE,NA}'::bpchar[]))
147. 0.000 0.000 ↓ 0.0 0

Index Scan using c_invoice_ref_invoice_sales_id on public.c_invoice c_invoice_1 (cost=0.43..2.50 rows=1 width=6) (never executed)

  • Output: c_invoice_1.c_invoice_id, c_invoice_1.ad_client_id, c_invoice_1.ad_org_id, c_invoice_1.isactive, c_invoice_1.created, c_invoice_1.createdby, c_invoice_1.updated, c_invoice_1.updatedby, c_invoice_1.issotrx, c_invoice_1.documentno, c_invoice_1.docstatus, c_invoice_1.docaction, c_invoice_1.processing, c_invoice_1.processed, c_invoice_1.posted, c_invoice_1.c_doctype_id, c_invoice_1.c_doctypetarget_id, c_invoice_1.c_order_id, c_invoice_1.description, c_invoice_1.isapproved, c_invoice_1.istransferred, c_invoice_1.isprinted, c_invoice_1.salesrep_id, c_invoice_1.dateinvoiced, c_invoice_1.dateprinted, c_invoice_1.dateacct, c_invoice_1.c_bpartner_id, c_invoice_1.c_bpartner_location_id, c_invoice_1.poreference, c_invoice_1.isdiscountprinted, c_invoice_1.dateordered, c_invoice_1.c_currency_id, c_invoice_1.paymentrule, c_invoice_1.c_paymentterm_id, c_invoice_1.c_charge_id, c_invoice_1.chargeamt, c_invoice_1.totallines, c_invoice_1.grandtotal, c_invoice_1.m_pricelist_id, c_invoice_1.istaxincluded, c_invoice_1.c_campaign_id, c_invoice_1.c_project_id, c_invoice_1.c_activity_id, c_invoice_1.ispaid, c_invoice_1.c_payment_id, c_invoice_1.c_cashline_id, c_invoice_1.createfrom, c_invoice_1.generateto, c_invoice_1.sendemail, c_invoice_1.ad_user_id, c_invoice_1.copyfrom, c_invoice_1.isselfservice, c_invoice_1.ad_orgtrx_id, c_invoice_1.user1_id, c_invoice_1.user2_id, c_invoice_1.c_conversiontype_id, c_invoice_1.ispayschedulevalid, c_invoice_1.ref_invoice_id, c_invoice_1.isindispute, c_invoice_1.exme_ctapacext_id, c_invoice_1.descfromaseg, c_invoice_1.precfromaseg, c_invoice_1.documentnoext, c_invoice_1.afecta_caja, c_invoice_1.c_cashbook_id, c_invoice_1.discountporcent, c_invoice_1.discountamt, c_invoice_1.address1, c_invoice_1.address2, c_invoice_1.city, c_invoice_1.postal, c_invoice_1.c_country_id, c_invoice_1.c_region_id, c_invoice_1.address3, c_invoice_1.exme_paciente_id, c_invoice_1.exme_medico_id, c_invoice_1.nombre_medico, c_invoice_1.nombre_paciente, c_invoice_1.exme_estserv_id, c_invoice_1.c_cash_id, c_invoice_1.canceledby, c_invoice_1.motivocancel, c_invoice_1.exme_motivocancel_id, c_invoice_1.isprintedpre, c_invoice_1.updatedbycancel, c_invoice_1.numext, c_invoice_1.numin, c_invoice_1.sexo, c_invoice_1.fechanac, c_invoice_1.invoicephone, c_invoice_1.exme_towncouncil_id, c_invoice_1.tipooperacion, c_invoice_1.observation, c_invoice_1.dunninggrace, c_invoice_1.m_rma_id, c_invoice_1.c_dunninglevel_id, c_invoice_1.invoicecollectiontype, c_invoice_1.reversal_id, c_invoice_1.verpoliza, c_invoice_1.isgenerated, c_invoice_1.globaldiscount, c_invoice_1.sello, c_invoice_1.cadena, c_invoice_1.exme_ctapac_id, c_invoice_1.conftype, c_invoice_1.multiple_id, c_invoice_1.ismultiple, c_invoice_1.partner, c_invoice_1.uuid, c_invoice_1.estserv, c_invoice_1.prepayment, c_invoice_1.backoffice, c_invoice_1.discounttaxamt, c_invoice_1.taxamt, c_invoice_1.exme_claimpayment_id, c_invoice_1.coaseguro, c_invoice_1.deducible, c_invoice_1.coaseguromed, c_invoice_1.copago, c_invoice_1.coaseguroamt, c_invoice_1.deducibleamt, c_invoice_1.coaseguromedamt, c_invoice_1.copagoamt, c_invoice_1.ref_invoice_sales_id, c_invoice_1.isinvoiced, c_invoice_1.isorderfaclinecategory, c_invoice_1.trxtype, c_invoice_1.rebate, c_invoice_1.sortby, c_invoice_1.addenda, c_invoice_1.sellosat, c_invoice_1.certificadosat, c_invoice_1.nocertificado, c_invoice_1.certificado, c_invoice_1.rate, c_invoice_1.m_inout_id, c_invoice_1.generatedfrom, c_invoice_1.typeacct, c_invoice_1.detailpayment, c_invoice_1.c_cash_cancel_id, c_invoice_1.datecanceled, c_invoice_1.exme_areacaja_id, c_invoice_1.accountno, c_invoice_1.post, c_invoice_1.statusuuid, c_invoice_1.canceldescription, c_invoice_1.versionno, c_invoice_1.emprelationship, c_invoice_1.perception, c_invoice_1.comp_ditto, c_invoice_1.perceptioniva, c_invoice_1.afip, c_invoice_1.date_comp, c_invoice_1.typefac_ditto
  • Index Cond: ((cpe_4.c_invoice_id = c_invoice_1.ref_invoice_sales_id) AND (c_invoice_1.ref_invoice_sales_id IS NOT NULL))
  • Filter: (c_invoice_1.ad_org_id = $48)
148. 0.033 1,598.086 ↓ 0.0 0 1

WindowAgg (cost=0.03..0.05 rows=1 width=48) (actual time=1,598.086..1,598.086 rows=0 loops=1)

  • Output: cf_2.exme_ctapac_id, sum(cf_2.facturado) OVER (?)
  • Buffers: shared hit=9243 read=87813
149. 0.017 1,598.053 ↓ 0.0 0 1

Sort (cost=0.03..0.04 rows=1 width=48) (actual time=1,598.053..1,598.053 rows=0 loops=1)

  • Output: cf_2.exme_ctapac_id, cf_2.facturado
  • Sort Key: cf_2.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=9243 read=87813
150. 1,598.036 1,598.036 ↓ 0.0 0 1

CTE Scan on cargosrem cf_2 (cost=0.00..0.02 rows=1 width=48) (actual time=1,598.036..1,598.036 rows=0 loops=1)

  • Output: cf_2.exme_ctapac_id, cf_2.facturado
  • Buffers: shared hit=9243 read=87813
151.          

CTE anticipos_sa

152. 0.075 174.714 ↓ 30.0 30 1

HashAggregate (cost=31,600.08..31,600.09 rows=1 width=48) (actual time=174.707..174.714 rows=30 loops=1)

  • Output: a.exme_ctapac_id, (sum(a.anticipos) OVER (?))
  • Group Key: a.exme_ctapac_id, sum(a.anticipos) OVER (?)
  • Buffers: shared hit=62703 read=23871
153.          

CTE a

154. 0.018 174.400 ↓ 49.0 49 1

Unique (cost=31,600.01..31,600.02 rows=1 width=44) (actual time=174.352..174.400 rows=49 loops=1)

  • Output: p_1.exme_ctapac_id, (CASE WHEN (p_1.isreceipt = 'N'::bpchar) THEN p_1.amount ELSE p_1.payamt END), cp_6.c_payment_id
  • Buffers: shared hit=62703 read=23871
155.          

Initplan (forUnique)

156. 0.024 0.024 ↑ 1.0 1 1

CTE Scan on params params_16 (cost=0.00..0.02 rows=1 width=32) (actual time=0.024..0.024 rows=1 loops=1)

  • Output: params_16.org_id
157. 0.005 0.005 ↑ 1.0 1 1

CTE Scan on params params_17 (cost=0.00..0.02 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=1)

  • Output: params_17.org_id
158. 0.092 174.353 ↓ 49.0 49 1

Sort (cost=31,599.97..31,599.97 rows=1 width=44) (actual time=174.348..174.353 rows=49 loops=1)

  • Output: p_1.exme_ctapac_id, (CASE WHEN (p_1.isreceipt = 'N'::bpchar) THEN p_1.amount ELSE p_1.payamt END), cp_6.c_payment_id
  • Sort Key: p_1.exme_ctapac_id, (CASE WHEN (p_1.isreceipt = 'N'::bpchar) THEN p_1.amount ELSE p_1.payamt END), cp_6.c_payment_id
  • Sort Method: quicksort Memory: 28kB
  • Buffers: shared hit=62703 read=23871
159. 0.432 174.261 ↓ 49.0 49 1

Nested Loop (cost=1,001.71..31,599.96 rows=1 width=44) (actual time=92.949..174.261 rows=49 loops=1)

  • Output: p_1.exme_ctapac_id, CASE WHEN (p_1.isreceipt = 'N'::bpchar) THEN p_1.amount ELSE p_1.payamt END, cp_6.c_payment_id
  • Inner Unique: true
  • Buffers: shared hit=62703 read=23871
160. 0.173 170.649 ↓ 530.0 530 1

Nested Loop (cost=1,001.28..31,599.37 rows=1 width=31) (actual time=10.859..170.649 rows=530 loops=1)

  • Output: cp_6.c_payment_id, p_1.exme_ctapac_id, p_1.isreceipt, p_1.amount, p_1.payamt, cpe_5.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=60582 read=23871
161. 36.060 166.766 ↓ 530.0 530 1

Gather (cost=1,000.86..31,593.55 rows=1 width=31) (actual time=10.822..166.766 rows=530 loops=1)

  • Output: cp_6.c_payment_id, cp_6.exme_ctapacext_id, p_1.exme_ctapac_id, p_1.isreceipt, p_1.amount, p_1.payamt
  • Workers Planned: 2
  • Params Evaluated: $57
  • Workers Launched: 2
  • Buffers: shared hit=58654 read=23677
162. 58.763 130.706 ↓ 177.0 177 3

Nested Loop Left Join (cost=0.85..30,593.45 rows=1 width=31) (actual time=3.379..130.706 rows=177 loops=3)

  • Output: cp_6.c_payment_id, cp_6.exme_ctapacext_id, p_1.exme_ctapac_id, p_1.isreceipt, p_1.amount, p_1.payamt
  • Filter: (al.c_allocationline_id IS NULL)
  • Rows Removed by Filter: 11000
  • Buffers: shared hit=58654 read=23677
  • Worker 0: actual time=4.878..117.465 rows=148 loops=1
  • Buffers: shared hit=14207 read=5550
  • Worker 1: actual time=2.559..117.400 rows=129 loops=1
  • Buffers: shared hit=13520 read=5775
163. 41.298 71.924 ↑ 1.6 2,874 3

Nested Loop (cost=0.42..25,534.99 rows=4,524 width=37) (actual time=0.185..71.924 rows=2,874 loops=3)

  • Output: cp_6.c_payment_id, cp_6.exme_ctapacext_id, p_1.exme_ctapac_id, p_1.isreceipt, p_1.amount, p_1.payamt, p_1.c_payment_id
  • Inner Unique: true
  • Buffers: shared hit=26987 read=11240
  • Worker 0: actual time=0.233..64.096 rows=2052 loops=1
  • Buffers: shared hit=6464 read=2657
  • Worker 1: actual time=0.241..64.170 rows=1995 loops=1
  • Buffers: shared hit=6122 read=2780
164. 30.613 30.613 ↑ 1.6 2,874 3

Parallel Seq Scan on public.exme_ctapacpag cp_6 (cost=0.00..5,077.10 rows=4,524 width=12) (actual time=0.099..30.613 rows=2,874 loops=3)

  • Output: cp_6.exme_ctapacpag_id, cp_6.ad_client_id, cp_6.ad_org_id, cp_6.isactive, cp_6.created, cp_6.createdby, cp_6.updated, cp_6.updatedby, cp_6.c_payment_id, cp_6.exme_ctapacext_id, cp_6.ispay, cp_6.disponible, cp_6.sedevolvio, cp_6.aplicado
  • Filter: (cp_6.ad_org_id = $57)
  • Rows Removed by Filter: 83981
  • Buffers: shared read=3720
  • Worker 0: actual time=0.114..26.362 rows=2052 loops=1
  • Buffers: shared read=907
  • Worker 1: actual time=0.154..26.685 rows=1995 loops=1
  • Buffers: shared read=919
165. 0.013 0.013 ↑ 1.0 1 8,622

Index Scan using c_payment_pkey on public.c_payment p_1 (cost=0.42..4.52 rows=1 width=25) (actual time=0.013..0.013 rows=1 loops=8,622)

  • Output: p_1.c_payment_id, p_1.ad_client_id, p_1.ad_org_id, p_1.isactive, p_1.created, p_1.createdby, p_1.updated, p_1.updatedby, p_1.documentno, p_1.datetrx, p_1.isreceipt, p_1.c_doctype_id, p_1.trxtype, p_1.c_bankaccount_id, p_1.c_bpartner_id, p_1.c_invoice_id, p_1.c_bp_bankaccount_id, p_1.c_paymentbatch_id, p_1.tendertype, p_1.creditcardtype, p_1.creditcardnumber, p_1.creditcardvv, p_1.creditcardexpmm, p_1.creditcardexpyy, p_1.micr, p_1.routingno, p_1.accountno, p_1.checkno, p_1.a_name, p_1.a_street, p_1.a_city, p_1.a_state, p_1.a_zip, p_1.a_ident_dl, p_1.a_ident_ssn, p_1.a_email, p_1.voiceauthcode, p_1.orig_trxid, p_1.ponum, p_1.c_currency_id, p_1.payamt, p_1.discountamt, p_1.writeoffamt, p_1.taxamt, p_1.isapproved, p_1.r_pnref, p_1.r_result, p_1.r_respmsg, p_1.r_authcode, p_1.r_avsaddr, p_1.r_avszip, p_1.r_info, p_1.processing, p_1.oprocessing, p_1.docstatus, p_1.docaction, p_1.isreconciled, p_1.isallocated, p_1.isonline, p_1.processed, p_1.posted, p_1.isoverunderpayment, p_1.overunderamt, p_1.a_country, p_1.c_project_id, p_1.isselfservice, p_1.chargeamt, p_1.c_charge_id, p_1.isdelayedcapture, p_1.r_authcode_dc, p_1.r_cvv2match, p_1.r_pnref_dc, p_1.swipe, p_1.ad_orgtrx_id, p_1.c_campaign_id, p_1.c_activity_id, p_1.user1_id, p_1.user2_id, p_1.c_conversiontype_id, p_1.description, p_1.dateacct, p_1.c_order_id, p_1.isprepayment, p_1.exme_ctapac_id, p_1.recibono, p_1.ref_payment_id, p_1.reversal_id, p_1.c_cashbook_id, p_1.verpoliza, p_1.exme_citamedica_id, p_1.payconcept, p_1.exme_adjustmenttype_id, p_1.paymenttype, p_1.beginningbalance, p_1.endingbalance, p_1.amount, p_1.exme_paciente_id, p_1.exme_claimpayment_id, p_1.conftype, p_1.creditmemo, p_1.backoffice, p_1.exme_partidapres_id, p_1.ref_invoice_id, p_1.type, p_1.amtsubtract, p_1.rate, p_1.c_bank_id, p_1.name, p_1.c_bankreciving_id, p_1.receivingbankacct, p_1.taxid, p_1.typeacct, p_1.amtcheckdeposited, p_1.amtcheck, p_1.exme_methodpaymentcode_id, p_1.exme_formapago_id, p_1.versionno, p_1.isdevol, p_1.isconsolid
  • Index Cond: (p_1.c_payment_id = cp_6.c_payment_id)
  • Buffers: shared hit=26987 read=7520
  • Worker 0: actual time=0.016..0.016 rows=1 loops=2052
  • Buffers: shared hit=6464 read=1750
  • Worker 1: actual time=0.017..0.017 rows=1 loops=1995
  • Buffers: shared hit=6122 read=1861
166. 0.019 0.019 ↑ 2.5 4 8,622

Index Scan using callocationline_paymnent_idx on public.c_allocationline al (cost=0.43..1.02 rows=10 width=13) (actual time=0.013..0.019 rows=4 loops=8,622)

  • Output: al.c_allocationline_id, al.ad_client_id, al.ad_org_id, al.isactive, al.created, al.createdby, al.updated, al.updatedby, al.allocationno, al.datetrx, al.ismanual, al.c_invoice_id, al.c_bpartner_id, al.c_order_id, al.c_payment_id, al.c_cashline_id, al.amount, al.discountamt, al.writeoffamt, al.posted, al.overunderamt, al.c_allocationhdr_id, al.c_charge_id, al.amtacct, al.creditmemo, al.c_payselectionline_id, al.rate, al.gain, al.amtbadge, al.typeacct, al.exme_paymentelectronic_id, al.ref_invoice_id
  • Index Cond: (al.c_payment_id = p_1.c_payment_id)
  • Buffers: shared hit=31667 read=12437
  • Worker 0: actual time=0.016..0.024 rows=4 loops=2052
  • Buffers: shared hit=7743 read=2893
  • Worker 1: actual time=0.017..0.025 rows=4 loops=1995
  • Buffers: shared hit=7398 read=2995
167. 3.710 3.710 ↑ 1.0 1 530

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe_5 (cost=0.43..5.82 rows=1 width=12) (actual time=0.007..0.007 rows=1 loops=530)

  • Output: cpe_5.exme_ctapacext_id, cpe_5.ad_client_id, cpe_5.ad_org_id, cpe_5.isactive, cpe_5.created, cpe_5.createdby, cpe_5.updated, cpe_5.updatedby, cpe_5.documentno, cpe_5.docstatus, cpe_5.docaction, cpe_5.processing, cpe_5.processed, cpe_5.c_doctype_id, cpe_5.c_doctypetarget_id, cpe_5.description, cpe_5.isapproved, cpe_5.isprinted, cpe_5.dateordered, cpe_5.dateacct, cpe_5.c_bpartner_id, cpe_5.c_bpartner_location_id, cpe_5.c_charge_id, cpe_5.chargeamt, cpe_5.totallines, cpe_5.grandtotal, cpe_5.ad_user_id, cpe_5.ad_orgtrx_id, cpe_5.ref_ctapacext_id, cpe_5.desctoglobal, cpe_5.coaseguro, cpe_5.deducible, cpe_5.c_invoice_id, cpe_5.exme_ctapac_id, cpe_5.rfc, cpe_5.extensionno, cpe_5.iscoasegpercent, cpe_5.isdeducincoaseg, cpe_5.desctoglobalamt, cpe_5.observacion, cpe_5.c_location_id, cpe_5.anticipo, cpe_5.coaseguromed, cpe_5.copago, cpe_5.taxamt, cpe_5.coaseguroamt, cpe_5.deducibleamt, cpe_5.coaseguromedamt, cpe_5.copagoamt, cpe_5.isdiscpercent, cpe_5.isdeducpercent, cpe_5.iscoasmedpercent, cpe_5.iscoppercent, cpe_5.conftype, cpe_5.institutionalstatus, cpe_5.institutionalstep, cpe_5.professionalstatus, cpe_5.professionalstep, cpe_5.chargestatus, cpe_5.discounttaxamt, cpe_5.isorderfaclinecategory, cpe_5.coasegurotax, cpe_5.deducibletax, cpe_5.coaseguromedtax, cpe_5.copagotax, cpe_5.emprelationship
  • Index Cond: (cpe_5.exme_ctapacext_id = cp_6.exme_ctapacext_id)
  • Buffers: shared hit=1928 read=194
168. 3.180 3.180 ↓ 0.0 0 530

Index Scan using exme_ctapac_pkey on public.exme_ctapac cpac (cost=0.42..0.58 rows=1 width=6) (actual time=0.006..0.006 rows=0 loops=530)

  • Output: cpac.exme_ctapac_id, cpac.ad_client_id, cpac.ad_org_id, cpac.isactive, cpac.created, cpac.createdby, cpac.updated, cpac.updatedby, cpac.documentno, cpac.docstatus, cpac.docaction, cpac.processing, cpac.processed, cpac.c_doctype_id, cpac.c_doctypetarget_id, cpac.description, cpac.isapproved, cpac.iscreditapproved, cpac.isinvoiced, cpac.isprinted, cpac.dateordered, cpac.dateprinted, cpac.dateacct, cpac.priorityrule, cpac.grandtotal, cpac.m_pricelist_id, cpac.c_campaign_id, cpac.c_project_id, cpac.c_activity_id, cpac.ad_user_id, cpac.ad_orgtrx_id, cpac.user1_id, cpac.user2_id, cpac.fechacancel, cpac.exme_paciente_id, cpac.exme_especialidad_id, cpac.exme_motivocita_id, cpac.estatus, cpac.exme_medico_id, cpac.ref_ctapac_id, cpac.c_currency_id, cpac.ad_printformat_id, cpac.impcontrato, cpac.impconsent, cpac.impdatos, cpac.impbrazalete, cpac.exme_diagnostico_id, cpac.exme_cama_id, cpac.tipoarea, cpac.fechacargodiario, cpac.fechacierre, cpac.exme_paqbase_version_id, cpac.exme_ctapacext_id, cpac.exme_estserv_id, cpac.isuso, cpac.isbloqueada, cpac.isautorizada, cpac.diagnostico_ingreso, cpac.fechaalta, cpac.actualizadoalta, cpac.statusalta, cpac.exme_camaing_id, cpac.fechaprealta, cpac.actualizadoprealta, cpac.isfactespec, cpac.ref_ctapacfam_id, cpac.exme_descpreciofijo_id, cpac.tiposangre, cpac.exme_tipotrasplante_id, cpac.exme_motivoegreso_id, cpac.casosmedicos, cpac.exme_estserving_id, cpac.fechatraslado, cpac.exme_procedencia_id, cpac.isgenerated, cpac.statuseleg, cpac.instruccionalta, cpac.nombrearchivo, cpac.formatoarchivo, cpac.archivo, cpac.informealta, cpac.exme_medico2_id, cpac.exme_especialidad2_id, cpac.exme_dischargestatus_id, cpac.resstatus, cpac.billingstatus, cpac.exme_tipoprod_id, cpac.drg, cpac.exme_tipopaciente_id, cpac.exme_arrivalmode_id, cpac.exme_admittype_id, cpac.exme_admitsource_id, cpac.isnewborn, cpac.exme_beneficiosh_id, cpac.exme_estservprov_id, cpac.billdate, cpac.exme_area_id, cpac.ref_unit_id, cpac.encounterstatus, cpac.exme_medicorefer_id, cpac.exme_especialidadrefer_id, cpac.exme_ctapacrefer_id, cpac.isidentifier, cpac.email, cpac.requester, cpac.fechaenv, cpac.departuredate, cpac.exme_pos_id, cpac.exme_drg_id, cpac.noinsurancecoverage, cpac.nostatementage, cpac.validonqueue, cpac.exme_accompaniedby_id, cpac.exme_transport_mode_id, cpac.exme_discharged_via_id, cpac.comments, cpac.exme_institucion_id, cpac.billingtype, cpac.coded, cpac.codingdate, cpac.codedprof, cpac.codingdateprof, cpac.institutionalstatus, cpac.institutionalstep, cpac.isvalid, cpac.nombre_pac, cpac.mrn, cpac.processingpaq, cpac.processingpaq2, cpac.isclosed, cpac.exme_eventmerge_id, cpac.fallrisk, cpac.triage, cpac.apollo_policy, cpac.apollo_claim
  • Index Cond: (cpac.exme_ctapac_id = cpe_5.exme_ctapac_id)
  • Filter: ((COALESCE(cpac.fechaalta, cpac.fechacierre) IS NULL) AND (cpac.fechacancel IS NULL) AND (cpac.ad_org_id = $56) AND (cpac.isactive = 'Y'::bpchar) AND ((cpac.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=2121
169. 0.138 174.639 ↓ 49.0 49 1

WindowAgg (cost=0.03..0.05 rows=1 width=48) (actual time=174.557..174.639 rows=49 loops=1)

  • Output: a.exme_ctapac_id, sum(a.anticipos) OVER (?)
  • Buffers: shared hit=62703 read=23871
170. 0.042 174.501 ↓ 49.0 49 1

Sort (cost=0.03..0.04 rows=1 width=48) (actual time=174.495..174.501 rows=49 loops=1)

  • Output: a.exme_ctapac_id, a.anticipos
  • Sort Key: a.exme_ctapac_id
  • Sort Method: quicksort Memory: 27kB
  • Buffers: shared hit=62703 read=23871
171. 174.459 174.459 ↓ 49.0 49 1

CTE Scan on a (cost=0.00..0.02 rows=1 width=48) (actual time=174.379..174.459 rows=49 loops=1)

  • Output: a.exme_ctapac_id, a.anticipos
  • Buffers: shared hit=62703 read=23871
172.          

CTE anticipos_a

173. 0.058 195.676 ↓ 1.6 8 1

HashAggregate (cost=34,379.07..34,379.12 rows=5 width=48) (actual time=195.673..195.676 rows=8 loops=1)

  • Output: a_1.exme_ctapac_id, (sum(a_1.anticipos) OVER (?))
  • Group Key: a_1.exme_ctapac_id, sum(a_1.anticipos) OVER (?)
  • Buffers: shared hit=85925 read=21575 written=372
174.          

CTE a

175. 0.053 195.460 ↓ 5.2 26 1

Unique (cost=34,378.75..34,378.80 rows=5 width=44) (actual time=195.401..195.460 rows=26 loops=1)

  • Output: p_2.exme_ctapac_id, (((al_1.amount + al_1.discountamt) + al_1.writeoffamt)), al_1.c_allocationline_id
  • Buffers: shared hit=85925 read=21575 written=372
176.          

Initplan (forUnique)

177. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params params_18 (cost=0.00..0.02 rows=1 width=32) (actual time=0.003..0.004 rows=1 loops=1)

  • Output: params_18.org_id
178. 0.002 0.002 ↑ 1.0 1 1

CTE Scan on params params_19 (cost=0.00..0.02 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=1)

  • Output: params_19.org_id
179. 0.094 195.401 ↓ 10.4 52 1

Sort (cost=34,378.71..34,378.72 rows=5 width=44) (actual time=195.397..195.401 rows=52 loops=1)

  • Output: p_2.exme_ctapac_id, (((al_1.amount + al_1.discountamt) + al_1.writeoffamt)), al_1.c_allocationline_id
  • Sort Key: p_2.exme_ctapac_id, (((al_1.amount + al_1.discountamt) + al_1.writeoffamt)), al_1.c_allocationline_id
  • Sort Method: quicksort Memory: 29kB
  • Buffers: shared hit=85925 read=21575 written=372
180. 0.000 195.307 ↓ 10.4 52 1

Nested Loop (cost=1,001.71..34,378.65 rows=5 width=44) (actual time=137.201..195.307 rows=52 loops=1)

  • Output: p_2.exme_ctapac_id, ((al_1.amount + al_1.discountamt) + al_1.writeoffamt), al_1.c_allocationline_id
  • Buffers: shared hit=85925 read=21575 written=372
181. 32.521 194.865 ↓ 65.0 65 1

Gather (cost=1,001.28..34,376.37 rows=1 width=18) (actual time=119.694..194.865 rows=65 loops=1)

  • Output: cp_7.c_payment_id, p_2.exme_ctapac_id, p_2.c_payment_id
  • Workers Planned: 2
  • Params Evaluated: $65, $66
  • Workers Launched: 2
  • Buffers: shared hit=85757 read=21518 written=372
182. 31.375 162.344 ↓ 22.0 22 3

Nested Loop (cost=1.28..33,376.27 rows=1 width=18) (actual time=87.284..162.344 rows=22 loops=3)

  • Output: cp_7.c_payment_id, p_2.exme_ctapac_id, p_2.c_payment_id
  • Inner Unique: true
  • Buffers: shared hit=85757 read=21518 written=372
  • Worker 0: actual time=57.357..151.130 rows=17 loops=1
  • Buffers: shared hit=23225 read=5829 written=108
  • Worker 1: actual time=93.884..151.268 rows=24 loops=1
  • Buffers: shared hit=23140 read=5843 written=102
183. 47.492 130.959 ↓ 2.4 2,874 3

Nested Loop (cost=0.85..32,664.24 rows=1,221 width=24) (actual time=0.219..130.959 rows=2,874 loops=3)

  • Output: cp_7.c_payment_id, cpe_6.exme_ctapac_id, p_2.exme_ctapac_id, p_2.c_payment_id
  • Inner Unique: true
  • Buffers: shared hit=53242 read=19501 written=339
  • Worker 0: actual time=0.296..121.404 rows=2333 loops=1
  • Buffers: shared hit=14424 read=5281 written=99
  • Worker 1: actual time=0.243..121.727 rows=2326 loops=1
  • Buffers: shared hit=14337 read=5329 written=92
184. 48.924 83.452 ↓ 2.4 2,874 3

Nested Loop (cost=0.42..25,557.61 rows=1,221 width=24) (actual time=0.144..83.452 rows=2,874 loops=3)

  • Output: cp_7.exme_ctapacext_id, cp_7.c_payment_id, p_2.exme_ctapac_id, p_2.c_payment_id
  • Inner Unique: true
  • Buffers: shared hit=26822 read=11405 written=206
  • Worker 0: actual time=0.197..77.461 rows=2333 loops=1
  • Buffers: shared hit=7259 read=3111 written=58
  • Worker 1: actual time=0.155..78.584 rows=2326 loops=1
  • Buffers: shared hit=7170 read=3185 written=55
185. 34.512 34.512 ↑ 1.6 2,874 3

Parallel Seq Scan on public.exme_ctapacpag cp_7 (cost=0.00..5,077.10 rows=4,524 width=12) (actual time=0.061..34.512 rows=2,874 loops=3)

  • Output: cp_7.exme_ctapacpag_id, cp_7.ad_client_id, cp_7.ad_org_id, cp_7.isactive, cp_7.created, cp_7.createdby, cp_7.updated, cp_7.updatedby, cp_7.c_payment_id, cp_7.exme_ctapacext_id, cp_7.ispay, cp_7.disponible, cp_7.sedevolvio, cp_7.aplicado
  • Filter: (cp_7.ad_org_id = $66)
  • Rows Removed by Filter: 83981
  • Buffers: shared hit=2 read=3718 written=65
  • Worker 0: actual time=0.079..31.917 rows=2333 loops=1
  • Buffers: shared hit=1 read=1034 written=21
  • Worker 1: actual time=0.075..33.096 rows=2326 loops=1
  • Buffers: shared read=1044 written=18
186. 0.016 0.016 ↑ 1.0 1 8,622

Index Scan using c_payment_pkey on public.c_payment p_2 (cost=0.42..4.53 rows=1 width=12) (actual time=0.016..0.016 rows=1 loops=8,622)

  • Output: p_2.c_payment_id, p_2.ad_client_id, p_2.ad_org_id, p_2.isactive, p_2.created, p_2.createdby, p_2.updated, p_2.updatedby, p_2.documentno, p_2.datetrx, p_2.isreceipt, p_2.c_doctype_id, p_2.trxtype, p_2.c_bankaccount_id, p_2.c_bpartner_id, p_2.c_invoice_id, p_2.c_bp_bankaccount_id, p_2.c_paymentbatch_id, p_2.tendertype, p_2.creditcardtype, p_2.creditcardnumber, p_2.creditcardvv, p_2.creditcardexpmm, p_2.creditcardexpyy, p_2.micr, p_2.routingno, p_2.accountno, p_2.checkno, p_2.a_name, p_2.a_street, p_2.a_city, p_2.a_state, p_2.a_zip, p_2.a_ident_dl, p_2.a_ident_ssn, p_2.a_email, p_2.voiceauthcode, p_2.orig_trxid, p_2.ponum, p_2.c_currency_id, p_2.payamt, p_2.discountamt, p_2.writeoffamt, p_2.taxamt, p_2.isapproved, p_2.r_pnref, p_2.r_result, p_2.r_respmsg, p_2.r_authcode, p_2.r_avsaddr, p_2.r_avszip, p_2.r_info, p_2.processing, p_2.oprocessing, p_2.docstatus, p_2.docaction, p_2.isreconciled, p_2.isallocated, p_2.isonline, p_2.processed, p_2.posted, p_2.isoverunderpayment, p_2.overunderamt, p_2.a_country, p_2.c_project_id, p_2.isselfservice, p_2.chargeamt, p_2.c_charge_id, p_2.isdelayedcapture, p_2.r_authcode_dc, p_2.r_cvv2match, p_2.r_pnref_dc, p_2.swipe, p_2.ad_orgtrx_id, p_2.c_campaign_id, p_2.c_activity_id, p_2.user1_id, p_2.user2_id, p_2.c_conversiontype_id, p_2.description, p_2.dateacct, p_2.c_order_id, p_2.isprepayment, p_2.exme_ctapac_id, p_2.recibono, p_2.ref_payment_id, p_2.reversal_id, p_2.c_cashbook_id, p_2.verpoliza, p_2.exme_citamedica_id, p_2.payconcept, p_2.exme_adjustmenttype_id, p_2.paymenttype, p_2.beginningbalance, p_2.endingbalance, p_2.amount, p_2.exme_paciente_id, p_2.exme_claimpayment_id, p_2.conftype, p_2.creditmemo, p_2.backoffice, p_2.exme_partidapres_id, p_2.ref_invoice_id, p_2.type, p_2.amtsubtract, p_2.rate, p_2.c_bank_id, p_2.name, p_2.c_bankreciving_id, p_2.receivingbankacct, p_2.taxid, p_2.typeacct, p_2.amtcheckdeposited, p_2.amtcheck, p_2.exme_methodpaymentcode_id, p_2.exme_formapago_id, p_2.versionno, p_2.isdevol, p_2.isconsolid
  • Index Cond: (p_2.c_payment_id = cp_7.c_payment_id)
  • Filter: ((p_2.isreceipt = 'Y'::bpchar) AND (p_2.type = 'A'::bpchar))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=26820 read=7687 written=141
  • Worker 0: actual time=0.018..0.018 rows=1 loops=2333
  • Buffers: shared hit=7258 read=2077 written=37
  • Worker 1: actual time=0.018..0.018 rows=1 loops=2326
  • Buffers: shared hit=7170 read=2141 written=37
187. 0.015 0.015 ↑ 1.0 1 8,621

Index Scan using exme_ctapacext_pkey on public.exme_ctapacext cpe_6 (cost=0.43..5.82 rows=1 width=12) (actual time=0.015..0.015 rows=1 loops=8,621)

  • Output: cpe_6.exme_ctapacext_id, cpe_6.ad_client_id, cpe_6.ad_org_id, cpe_6.isactive, cpe_6.created, cpe_6.createdby, cpe_6.updated, cpe_6.updatedby, cpe_6.documentno, cpe_6.docstatus, cpe_6.docaction, cpe_6.processing, cpe_6.processed, cpe_6.c_doctype_id, cpe_6.c_doctypetarget_id, cpe_6.description, cpe_6.isapproved, cpe_6.isprinted, cpe_6.dateordered, cpe_6.dateacct, cpe_6.c_bpartner_id, cpe_6.c_bpartner_location_id, cpe_6.c_charge_id, cpe_6.chargeamt, cpe_6.totallines, cpe_6.grandtotal, cpe_6.ad_user_id, cpe_6.ad_orgtrx_id, cpe_6.ref_ctapacext_id, cpe_6.desctoglobal, cpe_6.coaseguro, cpe_6.deducible, cpe_6.c_invoice_id, cpe_6.exme_ctapac_id, cpe_6.rfc, cpe_6.extensionno, cpe_6.iscoasegpercent, cpe_6.isdeducincoaseg, cpe_6.desctoglobalamt, cpe_6.observacion, cpe_6.c_location_id, cpe_6.anticipo, cpe_6.coaseguromed, cpe_6.copago, cpe_6.taxamt, cpe_6.coaseguroamt, cpe_6.deducibleamt, cpe_6.coaseguromedamt, cpe_6.copagoamt, cpe_6.isdiscpercent, cpe_6.isdeducpercent, cpe_6.iscoasmedpercent, cpe_6.iscoppercent, cpe_6.conftype, cpe_6.institutionalstatus, cpe_6.institutionalstep, cpe_6.professionalstatus, cpe_6.professionalstep, cpe_6.chargestatus, cpe_6.discounttaxamt, cpe_6.isorderfaclinecategory, cpe_6.coasegurotax, cpe_6.deducibletax, cpe_6.coaseguromedtax, cpe_6.copagotax, cpe_6.emprelationship
  • Index Cond: (cpe_6.exme_ctapacext_id = cp_7.exme_ctapacext_id)
  • Buffers: shared hit=26420 read=8096 written=133
  • Worker 0: actual time=0.017..0.017 rows=1 loops=2333
  • Buffers: shared hit=7165 read=2170 written=41
  • Worker 1: actual time=0.017..0.017 rows=1 loops=2326
  • Buffers: shared hit=7167 read=2144 written=37
188. 0.010 0.010 ↓ 0.0 0 8,621

Index Scan using exme_ctapac_pkey on public.exme_ctapac cpac_1 (cost=0.42..0.58 rows=1 width=6) (actual time=0.010..0.010 rows=0 loops=8,621)

  • Output: cpac_1.exme_ctapac_id, cpac_1.ad_client_id, cpac_1.ad_org_id, cpac_1.isactive, cpac_1.created, cpac_1.createdby, cpac_1.updated, cpac_1.updatedby, cpac_1.documentno, cpac_1.docstatus, cpac_1.docaction, cpac_1.processing, cpac_1.processed, cpac_1.c_doctype_id, cpac_1.c_doctypetarget_id, cpac_1.description, cpac_1.isapproved, cpac_1.iscreditapproved, cpac_1.isinvoiced, cpac_1.isprinted, cpac_1.dateordered, cpac_1.dateprinted, cpac_1.dateacct, cpac_1.priorityrule, cpac_1.grandtotal, cpac_1.m_pricelist_id, cpac_1.c_campaign_id, cpac_1.c_project_id, cpac_1.c_activity_id, cpac_1.ad_user_id, cpac_1.ad_orgtrx_id, cpac_1.user1_id, cpac_1.user2_id, cpac_1.fechacancel, cpac_1.exme_paciente_id, cpac_1.exme_especialidad_id, cpac_1.exme_motivocita_id, cpac_1.estatus, cpac_1.exme_medico_id, cpac_1.ref_ctapac_id, cpac_1.c_currency_id, cpac_1.ad_printformat_id, cpac_1.impcontrato, cpac_1.impconsent, cpac_1.impdatos, cpac_1.impbrazalete, cpac_1.exme_diagnostico_id, cpac_1.exme_cama_id, cpac_1.tipoarea, cpac_1.fechacargodiario, cpac_1.fechacierre, cpac_1.exme_paqbase_version_id, cpac_1.exme_ctapacext_id, cpac_1.exme_estserv_id, cpac_1.isuso, cpac_1.isbloqueada, cpac_1.isautorizada, cpac_1.diagnostico_ingreso, cpac_1.fechaalta, cpac_1.actualizadoalta, cpac_1.statusalta, cpac_1.exme_camaing_id, cpac_1.fechaprealta, cpac_1.actualizadoprealta, cpac_1.isfactespec, cpac_1.ref_ctapacfam_id, cpac_1.exme_descpreciofijo_id, cpac_1.tiposangre, cpac_1.exme_tipotrasplante_id, cpac_1.exme_motivoegreso_id, cpac_1.casosmedicos, cpac_1.exme_estserving_id, cpac_1.fechatraslado, cpac_1.exme_procedencia_id, cpac_1.isgenerated, cpac_1.statuseleg, cpac_1.instruccionalta, cpac_1.nombrearchivo, cpac_1.formatoarchivo, cpac_1.archivo, cpac_1.informealta, cpac_1.exme_medico2_id, cpac_1.exme_especialidad2_id, cpac_1.exme_dischargestatus_id, cpac_1.resstatus, cpac_1.billingstatus, cpac_1.exme_tipoprod_id, cpac_1.drg, cpac_1.exme_tipopaciente_id, cpac_1.exme_arrivalmode_id, cpac_1.exme_admittype_id, cpac_1.exme_admitsource_id, cpac_1.isnewborn, cpac_1.exme_beneficiosh_id, cpac_1.exme_estservprov_id, cpac_1.billdate, cpac_1.exme_area_id, cpac_1.ref_unit_id, cpac_1.encounterstatus, cpac_1.exme_medicorefer_id, cpac_1.exme_especialidadrefer_id, cpac_1.exme_ctapacrefer_id, cpac_1.isidentifier, cpac_1.email, cpac_1.requester, cpac_1.fechaenv, cpac_1.departuredate, cpac_1.exme_pos_id, cpac_1.exme_drg_id, cpac_1.noinsurancecoverage, cpac_1.nostatementage, cpac_1.validonqueue, cpac_1.exme_accompaniedby_id, cpac_1.exme_transport_mode_id, cpac_1.exme_discharged_via_id, cpac_1.comments, cpac_1.exme_institucion_id, cpac_1.billingtype, cpac_1.coded, cpac_1.codingdate, cpac_1.codedprof, cpac_1.codingdateprof, cpac_1.institutionalstatus, cpac_1.institutionalstep, cpac_1.isvalid, cpac_1.nombre_pac, cpac_1.mrn, cpac_1.processingpaq, cpac_1.processingpaq2, cpac_1.isclosed, cpac_1.exme_eventmerge_id, cpac_1.fallrisk, cpac_1.triage, cpac_1.apollo_policy, cpac_1.apollo_claim
  • Index Cond: (cpac_1.exme_ctapac_id = cpe_6.exme_ctapac_id)
  • Filter: ((COALESCE(cpac_1.fechaalta, cpac_1.fechacierre) IS NULL) AND (cpac_1.fechacancel IS NULL) AND (cpac_1.ad_org_id = $65) AND (cpac_1.isactive = 'Y'::bpchar) AND ((cpac_1.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=32515 read=2017 written=33
  • Worker 0: actual time=0.012..0.012 rows=0 loops=2333
  • Buffers: shared hit=8801 read=548 written=9
  • Worker 1: actual time=0.012..0.012 rows=0 loops=2326
  • Buffers: shared hit=8803 read=514 written=10
189. 0.780 0.780 ↑ 10.0 1 65

Index Scan using callocationline_paymnent_idx on public.c_allocationline al_1 (cost=0.43..2.16 rows=10 width=25) (actual time=0.011..0.012 rows=1 loops=65)

  • Output: al_1.c_allocationline_id, al_1.ad_client_id, al_1.ad_org_id, al_1.isactive, al_1.created, al_1.createdby, al_1.updated, al_1.updatedby, al_1.allocationno, al_1.datetrx, al_1.ismanual, al_1.c_invoice_id, al_1.c_bpartner_id, al_1.c_order_id, al_1.c_payment_id, al_1.c_cashline_id, al_1.amount, al_1.discountamt, al_1.writeoffamt, al_1.posted, al_1.overunderamt, al_1.c_allocationhdr_id, al_1.c_charge_id, al_1.amtacct, al_1.creditmemo, al_1.c_payselectionline_id, al_1.rate, al_1.gain, al_1.amtbadge, al_1.typeacct, al_1.exme_paymentelectronic_id, al_1.ref_invoice_id
  • Index Cond: (al_1.c_payment_id = p_2.c_payment_id)
  • Filter: (al_1.isactive = 'Y'::bpchar)
  • Buffers: shared hit=168 read=57
190. 0.075 195.618 ↓ 5.2 26 1

WindowAgg (cost=0.16..0.25 rows=5 width=48) (actual time=195.582..195.618 rows=26 loops=1)

  • Output: a_1.exme_ctapac_id, sum(a_1.anticipos) OVER (?)
  • Buffers: shared hit=85925 read=21575 written=372
191. 0.032 195.543 ↓ 5.2 26 1

Sort (cost=0.16..0.17 rows=5 width=48) (actual time=195.536..195.543 rows=26 loops=1)

  • Output: a_1.exme_ctapac_id, a_1.anticipos
  • Sort Key: a_1.exme_ctapac_id
  • Sort Method: quicksort Memory: 26kB
  • Buffers: shared hit=85925 read=21575 written=372
192. 195.511 195.511 ↓ 5.2 26 1

CTE Scan on a a_1 (cost=0.00..0.10 rows=5 width=48) (actual time=195.428..195.511 rows=26 loops=1)

  • Output: a_1.exme_ctapac_id, a_1.anticipos
  • Buffers: shared hit=85925 read=21575 written=372
193.          

CTE pagos

194. 0.012 962.981 ↓ 0.0 0 1

HashAggregate (cost=374,010.09..374,010.13 rows=4 width=48) (actual time=962.981..962.981 rows=0 loops=1)

  • Output: p_4.exme_ctapac_id, (sum(p_4.pago) OVER (?))
  • Group Key: p_4.exme_ctapac_id, sum(p_4.pago) OVER (?)
  • Buffers: shared hit=156297 read=54239
195.          

CTE pagoe

196. 0.028 962.890 ↓ 0.0 0 1

Append (cost=89,884.36..374,009.88 rows=4 width=38) (actual time=962.890..962.890 rows=0 loops=1)

  • Buffers: shared hit=156297 read=54239
197. 0.006 505.421 ↓ 0.0 0 1

Nested Loop (cost=89,884.36..89,896.21 rows=1 width=45) (actual time=505.421..505.421 rows=0 loops=1)

  • Output: al_2.c_invoice_id, ((al_2.amount + al_2.discountamt) + al_2.writeoffamt), si.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=7727 read=54156
198.          

Initplan (forNested Loop)

199. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params params_20 (cost=0.00..0.02 rows=1 width=32) (actual time=0.003..0.004 rows=1 loops=1)

  • Output: params_20.org_id
200. 0.018 505.403 ↓ 8.0 8 1

Nested Loop (cost=89,883.91..89,893.57 rows=1 width=32) (actual time=504.504..505.403 rows=8 loops=1)

  • Output: al_2.c_invoice_id, al_2.amount, al_2.discountamt, al_2.writeoffamt, al_2.c_cashline_id, si.exme_ctapac_id
  • Buffers: shared hit=7727 read=54156
201. 0.025 505.145 ↓ 8.0 8 1

Nested Loop (cost=89,883.48..89,892.60 rows=1 width=13) (actual time=504.452..505.145 rows=8 loops=1)

  • Output: si.exme_ctapac_id, si.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=7718 read=54133
202. 0.081 505.024 ↓ 8.0 16 1

Nested Loop (cost=89,883.20..89,891.96 rows=2 width=19) (actual time=504.391..505.024 rows=16 loops=1)

  • Output: si.exme_ctapac_id, si.c_doctype_id, si.c_invoice_id
  • Buffers: shared hit=7672 read=54131
203. 0.057 0.079 ↓ 48.0 48 1

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual time=0.052..0.079 rows=48 loops=1)

  • Output: pac.exme_ctapac_id
  • Group Key: pac.exme_ctapac_id
204. 0.022 0.022 ↓ 48.0 48 1

CTE Scan on pacientes pac (cost=0.00..0.02 rows=1 width=16) (actual time=0.003..0.022 rows=48 loops=1)

  • Output: pac.exme_ctapac_id, pac.mrn, pac.encounter, pac.nombre_pac, pac.gender, pac.birth_date, pac.age_at_admission, pac.room, pac.bed, pac.tipopac, pac.physician, pac.specialty, pac.admission_diagnosis, pac.admission_diagnosis_trunk, pac.patient_type, pac.service_unit, pac.dateordered, pac.admit_date, pac.discharge_date, pac.los, pac.institucion, pac.fecha_prealta, pac.prealta, pac.destino
205. 55.209 504.864 ↓ 0.0 0 48

Index Scan using ender_c_invoice_exme_ctapac on public.c_invoice si (cost=89,883.17..89,891.91 rows=2 width=19) (actual time=10.517..10.518 rows=0 loops=48)

  • Output: si.c_invoice_id, si.ad_client_id, si.ad_org_id, si.isactive, si.created, si.createdby, si.updated, si.updatedby, si.issotrx, si.documentno, si.docstatus, si.docaction, si.processing, si.processed, si.posted, si.c_doctype_id, si.c_doctypetarget_id, si.c_order_id, si.description, si.isapproved, si.istransferred, si.isprinted, si.salesrep_id, si.dateinvoiced, si.dateprinted, si.dateacct, si.c_bpartner_id, si.c_bpartner_location_id, si.poreference, si.isdiscountprinted, si.dateordered, si.c_currency_id, si.paymentrule, si.c_paymentterm_id, si.c_charge_id, si.chargeamt, si.totallines, si.grandtotal, si.m_pricelist_id, si.istaxincluded, si.c_campaign_id, si.c_project_id, si.c_activity_id, si.ispaid, si.c_payment_id, si.c_cashline_id, si.createfrom, si.generateto, si.sendemail, si.ad_user_id, si.copyfrom, si.isselfservice, si.ad_orgtrx_id, si.user1_id, si.user2_id, si.c_conversiontype_id, si.ispayschedulevalid, si.ref_invoice_id, si.isindispute, si.exme_ctapacext_id, si.descfromaseg, si.precfromaseg, si.documentnoext, si.afecta_caja, si.c_cashbook_id, si.discountporcent, si.discountamt, si.address1, si.address2, si.city, si.postal, si.c_country_id, si.c_region_id, si.address3, si.exme_paciente_id, si.exme_medico_id, si.nombre_medico, si.nombre_paciente, si.exme_estserv_id, si.c_cash_id, si.canceledby, si.motivocancel, si.exme_motivocancel_id, si.isprintedpre, si.updatedbycancel, si.numext, si.numin, si.sexo, si.fechanac, si.invoicephone, si.exme_towncouncil_id, si.tipooperacion, si.observation, si.dunninggrace, si.m_rma_id, si.c_dunninglevel_id, si.invoicecollectiontype, si.reversal_id, si.verpoliza, si.isgenerated, si.globaldiscount, si.sello, si.cadena, si.exme_ctapac_id, si.conftype, si.multiple_id, si.ismultiple, si.partner, si.uuid, si.estserv, si.prepayment, si.backoffice, si.discounttaxamt, si.taxamt, si.exme_claimpayment_id, si.coaseguro, si.deducible, si.coaseguromed, si.copago, si.coaseguroamt, si.deducibleamt, si.coaseguromedamt, si.copagoamt, si.ref_invoice_sales_id, si.isinvoiced, si.isorderfaclinecategory, si.trxtype, si.rebate, si.sortby, si.addenda, si.sellosat, si.certificadosat, si.nocertificado, si.certificado, si.rate, si.m_inout_id, si.generatedfrom, si.typeacct, si.detailpayment, si.c_cash_cancel_id, si.datecanceled, si.exme_areacaja_id, si.accountno, si.post, si.statusuuid, si.canceldescription, si.versionno, si.emprelationship, si.perception, si.comp_ditto, si.perceptioniva, si.afip, si.date_comp, si.typefac_ditto
  • Index Cond: (si.exme_ctapac_id = pac.exme_ctapac_id)
  • Filter: ((NOT (hashed SubPlan 38)) AND (si.isactive = 'Y'::bpchar) AND (si.issotrx = 'Y'::bpchar) AND (si.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=7672 read=54131
206.          

SubPlan (forIndex Scan)

207. 14.315 449.655 ↓ 120.4 59,694 1

Nested Loop (cost=0.56..89,881.50 rows=496 width=7) (actual time=0.232..449.655 rows=59,694 loops=1)

  • Output: ssi_1.ref_invoice_id
  • Buffers: shared hit=7572 read=54068
208. 3.714 3.714 ↓ 1.6 169 1

Seq Scan on public.c_doctype sd_1 (cost=0.00..347.14 rows=104 width=6) (actual time=0.042..3.714 rows=169 loops=1)

  • Output: sd_1.c_doctype_id, sd_1.ad_client_id, sd_1.ad_org_id, sd_1.isactive, sd_1.created, sd_1.createdby, sd_1.updated, sd_1.updatedby, sd_1.name, sd_1.printname, sd_1.description, sd_1.docbasetype, sd_1.issotrx, sd_1.docsubtypeso, sd_1.hasproforma, sd_1.c_doctypeproforma_id, sd_1.c_doctypeshipment_id, sd_1.c_doctypeinvoice_id, sd_1.isdocnocontrolled, sd_1.docnosequence_id, sd_1.gl_category_id, sd_1.hascharges, sd_1.documentnote, sd_1.isdefault, sd_1.documentcopies, sd_1.ad_printformat_id, sd_1.isdefaultcounterdoc, sd_1.isshipconfirm, sd_1.ispickqaconfirm, sd_1.isintransit, sd_1.issplitwhendifference, sd_1.c_doctypedifference_id, sd_1.iscreatecounter, sd_1.isindexed, sd_1.definitesequence_id, sd_1.isoverwriteseqoncomplete, sd_1.isoverwritedateoncomplete, sd_1.exme_typevouchercode_id, sd_1.exme_relationtypecode_id, sd_1.type
  • Filter: ((sd_1.docsubtypeso IS NULL) AND (sd_1.isactive = 'Y'::bpchar) AND (sd_1.docbasetype = 'ARC'::bpchar))
  • Rows Removed by Filter: 9174
  • Buffers: shared hit=1 read=206
209. 431.626 431.626 ↓ 1.5 353 169

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_1 (cost=0.56..858.60 rows=231 width=13) (actual time=0.032..2.554 rows=353 loops=169)

  • Output: ssi_1.isactive, ssi_1.c_doctype_id, ssi_1.docstatus, ssi_1.issotrx, ssi_1.c_invoice_id, ssi_1.ref_invoice_id, ssi_1.trxtype, ssi_1.issotrx
  • Index Cond: ((ssi_1.isactive = 'Y'::bpchar) AND (ssi_1.c_doctype_id = sd_1.c_doctype_id) AND (ssi_1.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_1.issotrx = 'Y'::bpchar) AND (ssi_1.trxtype = 'N'::bpchar))
  • Heap Fetches: 59694
  • Buffers: shared hit=7571 read=53862
210. 0.096 0.096 ↓ 0.0 0 16

Index Scan using c_doctype_c_doctype_id on public.c_doctype sd (cost=0.29..0.31 rows=1 width=6) (actual time=0.006..0.006 rows=0 loops=16)

  • Output: sd.c_doctype_id, sd.ad_client_id, sd.ad_org_id, sd.isactive, sd.created, sd.createdby, sd.updated, sd.updatedby, sd.name, sd.printname, sd.description, sd.docbasetype, sd.issotrx, sd.docsubtypeso, sd.hasproforma, sd.c_doctypeproforma_id, sd.c_doctypeshipment_id, sd.c_doctypeinvoice_id, sd.isdocnocontrolled, sd.docnosequence_id, sd.gl_category_id, sd.hascharges, sd.documentnote, sd.isdefault, sd.documentcopies, sd.ad_printformat_id, sd.isdefaultcounterdoc, sd.isshipconfirm, sd.ispickqaconfirm, sd.isintransit, sd.issplitwhendifference, sd.c_doctypedifference_id, sd.iscreatecounter, sd.isindexed, sd.definitesequence_id, sd.isoverwriteseqoncomplete, sd.isoverwritedateoncomplete, sd.exme_typevouchercode_id, sd.exme_relationtypecode_id, sd.type
  • Index Cond: (sd.c_doctype_id = si.c_doctype_id)
  • Filter: ((sd.isactive = 'Y'::bpchar) AND (sd.docbasetype = 'ARI'::bpchar) AND (sd.docsubtypeso = 'SR'::bpchar))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=46 read=2
211. 0.240 0.240 ↑ 1.0 1 8

Index Scan using c_allocationline_invoice on public.c_allocationline al_2 (cost=0.43..0.97 rows=1 width=25) (actual time=0.030..0.030 rows=1 loops=8)

  • Output: al_2.c_allocationline_id, al_2.ad_client_id, al_2.ad_org_id, al_2.isactive, al_2.created, al_2.createdby, al_2.updated, al_2.updatedby, al_2.allocationno, al_2.datetrx, al_2.ismanual, al_2.c_invoice_id, al_2.c_bpartner_id, al_2.c_order_id, al_2.c_payment_id, al_2.c_cashline_id, al_2.amount, al_2.discountamt, al_2.writeoffamt, al_2.posted, al_2.overunderamt, al_2.c_allocationhdr_id, al_2.c_charge_id, al_2.amtacct, al_2.creditmemo, al_2.c_payselectionline_id, al_2.rate, al_2.gain, al_2.amtbadge, al_2.typeacct, al_2.exme_paymentelectronic_id, al_2.ref_invoice_id
  • Index Cond: (al_2.c_invoice_id = si.c_invoice_id)
  • Filter: ((al_2.isactive = 'Y'::bpchar) AND (al_2.ad_org_id = $76))
  • Buffers: shared hit=9 read=23
212. 0.008 0.008 ↓ 0.0 0 8

Index Scan using c_cashline_pkey on public.c_cashline c_1 (cost=0.43..2.62 rows=1 width=6) (actual time=0.001..0.001 rows=0 loops=8)

  • Output: c_1.c_cashline_id, c_1.ad_client_id, c_1.ad_org_id, c_1.isactive, c_1.created, c_1.createdby, c_1.updated, c_1.updatedby, c_1.c_cash_id, c_1.line, c_1.description, c_1.cashtype, c_1.c_bankaccount_id, c_1.c_charge_id, c_1.c_invoice_id, c_1.c_currency_id, c_1.amount, c_1.discountamt, c_1.writeoffamt, c_1.isgenerated, c_1.processed, c_1.c_payment_id, c_1.exme_ctapac_id, c_1.exme_formapago_id, c_1.creditcardtype, c_1.creditcardnumber, c_1.creditcardvv, c_1.creditcardexpmm, c_1.creditcardexpyy, c_1.accountno, c_1.checkno, c_1.routingno, c_1.micr, c_1.isprepayment, c_1.a_name, c_1.recibono, c_1.cambio, c_1.exme_citamedica_id, c_1.iscancelled, c_1.ref_cash_id, c_1.typeacct, c_1.ref_cashline_id, c_1.exme_methodpaymentcode_id, c_1.rate
  • Index Cond: (c_1.c_cashline_id = al_2.c_cashline_id)
  • Filter: (c_1.exme_ctapac_id IS NULL)
213. 0.000 206.054 ↓ 0.0 0 1

Nested Loop (cost=126,430.17..126,446.07 rows=1 width=45) (actual time=206.053..206.054 rows=0 loops=1)

  • Output: al_3.c_invoice_id, ((al_3.amount + al_3.discountamt) + al_3.writeoffamt), i_3.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=64544 read=83
214.          

Initplan (forNested Loop)

215. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on params params_21 (cost=0.00..0.02 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=1)

  • Output: params_21.org_id
216. 0.021 0.021 ↑ 1.0 1 1

CTE Scan on params params_22 (cost=0.00..0.02 rows=1 width=32) (actual time=0.021..0.021 rows=1 loops=1)

  • Output: params_22.org_id
217. 0.043 206.053 ↓ 0.0 0 1

Nested Loop (cost=126,429.84..126,445.66 rows=1 width=31) (actual time=206.053..206.053 rows=0 loops=1)

  • Output: al_3.c_invoice_id, al_3.amount, al_3.discountamt, al_3.writeoffamt, i_3.exme_ctapac_id, i_3.c_doctype_id
  • Inner Unique: true
  • Buffers: shared hit=64544 read=83
218. 0.056 205.698 ↓ 24.0 24 1

Nested Loop (cost=126,429.42..126,443.46 rows=1 width=38) (actual time=204.837..205.698 rows=24 loops=1)

  • Output: al_3.c_invoice_id, al_3.amount, al_3.discountamt, al_3.writeoffamt, al_3.c_payment_id, i_3.exme_ctapac_id, i_3.c_doctype_id
  • Buffers: shared hit=64467 read=64
219. 0.086 205.402 ↓ 16.0 16 1

Nested Loop (cost=126,428.99..126,437.04 rows=1 width=19) (actual time=204.733..205.402 rows=16 loops=1)

  • Output: i_3.exme_ctapac_id, i_3.c_invoice_id, i_3.c_doctype_id
  • Buffers: shared hit=64405 read=55
220. 0.077 0.116 ↓ 48.0 48 1

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual time=0.067..0.116 rows=48 loops=1)

  • Output: pac_1.exme_ctapac_id
  • Group Key: pac_1.exme_ctapac_id
221. 0.039 0.039 ↓ 48.0 48 1

CTE Scan on pacientes pac_1 (cost=0.00..0.02 rows=1 width=16) (actual time=0.005..0.039 rows=48 loops=1)

  • Output: pac_1.exme_ctapac_id, pac_1.mrn, pac_1.encounter, pac_1.nombre_pac, pac_1.gender, pac_1.birth_date, pac_1.age_at_admission, pac_1.room, pac_1.bed, pac_1.tipopac, pac_1.physician, pac_1.specialty, pac_1.admission_diagnosis, pac_1.admission_diagnosis_trunk, pac_1.patient_type, pac_1.service_unit, pac_1.dateordered, pac_1.admit_date, pac_1.discharge_date, pac_1.los, pac_1.institucion, pac_1.fecha_prealta, pac_1.prealta, pac_1.destino
222. 33.528 205.200 ↓ 0.0 0 48

Index Scan using ender_c_invoice_ctapac on public.c_invoice i_3 (cost=126,428.97..126,437.00 rows=1 width=19) (actual time=4.274..4.275 rows=0 loops=48)

  • Output: i_3.c_invoice_id, i_3.ad_client_id, i_3.ad_org_id, i_3.isactive, i_3.created, i_3.createdby, i_3.updated, i_3.updatedby, i_3.issotrx, i_3.documentno, i_3.docstatus, i_3.docaction, i_3.processing, i_3.processed, i_3.posted, i_3.c_doctype_id, i_3.c_doctypetarget_id, i_3.c_order_id, i_3.description, i_3.isapproved, i_3.istransferred, i_3.isprinted, i_3.salesrep_id, i_3.dateinvoiced, i_3.dateprinted, i_3.dateacct, i_3.c_bpartner_id, i_3.c_bpartner_location_id, i_3.poreference, i_3.isdiscountprinted, i_3.dateordered, i_3.c_currency_id, i_3.paymentrule, i_3.c_paymentterm_id, i_3.c_charge_id, i_3.chargeamt, i_3.totallines, i_3.grandtotal, i_3.m_pricelist_id, i_3.istaxincluded, i_3.c_campaign_id, i_3.c_project_id, i_3.c_activity_id, i_3.ispaid, i_3.c_payment_id, i_3.c_cashline_id, i_3.createfrom, i_3.generateto, i_3.sendemail, i_3.ad_user_id, i_3.copyfrom, i_3.isselfservice, i_3.ad_orgtrx_id, i_3.user1_id, i_3.user2_id, i_3.c_conversiontype_id, i_3.ispayschedulevalid, i_3.ref_invoice_id, i_3.isindispute, i_3.exme_ctapacext_id, i_3.descfromaseg, i_3.precfromaseg, i_3.documentnoext, i_3.afecta_caja, i_3.c_cashbook_id, i_3.discountporcent, i_3.discountamt, i_3.address1, i_3.address2, i_3.city, i_3.postal, i_3.c_country_id, i_3.c_region_id, i_3.address3, i_3.exme_paciente_id, i_3.exme_medico_id, i_3.nombre_medico, i_3.nombre_paciente, i_3.exme_estserv_id, i_3.c_cash_id, i_3.canceledby, i_3.motivocancel, i_3.exme_motivocancel_id, i_3.isprintedpre, i_3.updatedbycancel, i_3.numext, i_3.numin, i_3.sexo, i_3.fechanac, i_3.invoicephone, i_3.exme_towncouncil_id, i_3.tipooperacion, i_3.observation, i_3.dunninggrace, i_3.m_rma_id, i_3.c_dunninglevel_id, i_3.invoicecollectiontype, i_3.reversal_id, i_3.verpoliza, i_3.isgenerated, i_3.globaldiscount, i_3.sello, i_3.cadena, i_3.exme_ctapac_id, i_3.conftype, i_3.multiple_id, i_3.ismultiple, i_3.partner, i_3.uuid, i_3.estserv, i_3.prepayment, i_3.backoffice, i_3.discounttaxamt, i_3.taxamt, i_3.exme_claimpayment_id, i_3.coaseguro, i_3.deducible, i_3.coaseguromed, i_3.copago, i_3.coaseguroamt, i_3.deducibleamt, i_3.coaseguromedamt, i_3.copagoamt, i_3.ref_invoice_sales_id, i_3.isinvoiced, i_3.isorderfaclinecategory, i_3.trxtype, i_3.rebate, i_3.sortby, i_3.addenda, i_3.sellosat, i_3.certificadosat, i_3.nocertificado, i_3.certificado, i_3.rate, i_3.m_inout_id, i_3.generatedfrom, i_3.typeacct, i_3.detailpayment, i_3.c_cash_cancel_id, i_3.datecanceled, i_3.exme_areacaja_id, i_3.accountno, i_3.post, i_3.statusuuid, i_3.canceldescription, i_3.versionno, i_3.emprelationship, i_3.perception, i_3.comp_ditto, i_3.perceptioniva, i_3.afip, i_3.date_comp, i_3.typefac_ditto
  • Index Cond: ((i_3.exme_ctapac_id = pac_1.exme_ctapac_id) AND (i_3.isactive = 'Y'::bpchar) AND (i_3.ad_org_id = $77))
  • Filter: ((NOT (hashed SubPlan 41)) AND (i_3.issotrx = 'Y'::bpchar) AND (i_3.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=64405 read=55
223.          

SubPlan (forIndex Scan)

224. 9.209 171.672 ↓ 116.4 59,695 1

Nested Loop (cost=0.56..126,427.25 rows=513 width=7) (actual time=0.118..171.672 rows=59,695 loops=1)

  • Output: ssi_2.ref_invoice_id
  • Buffers: shared hit=64296 read=1
225. 2.758 2.758 ↓ 1.6 169 1

Seq Scan on public.c_doctype dt_4 (cost=0.00..347.14 rows=104 width=6) (actual time=0.025..2.758 rows=169 loops=1)

  • Output: dt_4.c_doctype_id, dt_4.ad_client_id, dt_4.ad_org_id, dt_4.isactive, dt_4.created, dt_4.createdby, dt_4.updated, dt_4.updatedby, dt_4.name, dt_4.printname, dt_4.description, dt_4.docbasetype, dt_4.issotrx, dt_4.docsubtypeso, dt_4.hasproforma, dt_4.c_doctypeproforma_id, dt_4.c_doctypeshipment_id, dt_4.c_doctypeinvoice_id, dt_4.isdocnocontrolled, dt_4.docnosequence_id, dt_4.gl_category_id, dt_4.hascharges, dt_4.documentnote, dt_4.isdefault, dt_4.documentcopies, dt_4.ad_printformat_id, dt_4.isdefaultcounterdoc, dt_4.isshipconfirm, dt_4.ispickqaconfirm, dt_4.isintransit, dt_4.issplitwhendifference, dt_4.c_doctypedifference_id, dt_4.iscreatecounter, dt_4.isindexed, dt_4.definitesequence_id, dt_4.isoverwriteseqoncomplete, dt_4.isoverwritedateoncomplete, dt_4.exme_typevouchercode_id, dt_4.exme_relationtypecode_id, dt_4.type
  • Filter: ((dt_4.docsubtypeso IS NULL) AND (dt_4.isactive = 'Y'::bpchar) AND (dt_4.docbasetype = 'ARC'::bpchar))
  • Rows Removed by Filter: 9174
  • Buffers: shared hit=207
226. 159.705 159.705 ↓ 1.5 353 169

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_2 (cost=0.56..1,209.92 rows=239 width=13) (actual time=0.038..0.945 rows=353 loops=169)

  • Output: ssi_2.isactive, ssi_2.c_doctype_id, ssi_2.docstatus, ssi_2.issotrx, ssi_2.c_invoice_id, ssi_2.ref_invoice_id, ssi_2.trxtype, ssi_2.issotrx
  • Index Cond: ((ssi_2.isactive = 'Y'::bpchar) AND (ssi_2.c_doctype_id = dt_4.c_doctype_id) AND (ssi_2.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_2.issotrx = 'Y'::bpchar) AND (ssi_2.trxtype = ANY ('{N,X}'::bpchar[])))
  • Heap Fetches: 59695
  • Buffers: shared hit=64089 read=1
227. 0.240 0.240 ↓ 2.0 2 16

Index Scan using c_allocationline_invoice on public.c_allocationline al_3 (cost=0.43..6.41 rows=1 width=25) (actual time=0.013..0.015 rows=2 loops=16)

  • Output: al_3.c_allocationline_id, al_3.ad_client_id, al_3.ad_org_id, al_3.isactive, al_3.created, al_3.createdby, al_3.updated, al_3.updatedby, al_3.allocationno, al_3.datetrx, al_3.ismanual, al_3.c_invoice_id, al_3.c_bpartner_id, al_3.c_order_id, al_3.c_payment_id, al_3.c_cashline_id, al_3.amount, al_3.discountamt, al_3.writeoffamt, al_3.posted, al_3.overunderamt, al_3.c_allocationhdr_id, al_3.c_charge_id, al_3.amtacct, al_3.creditmemo, al_3.c_payselectionline_id, al_3.rate, al_3.gain, al_3.amtbadge, al_3.typeacct, al_3.exme_paymentelectronic_id, al_3.ref_invoice_id
  • Index Cond: (al_3.c_invoice_id = i_3.c_invoice_id)
  • Filter: ((al_3.isactive = 'Y'::bpchar) AND (al_3.ad_org_id = $80))
  • Buffers: shared hit=62 read=9
228. 0.312 0.312 ↓ 0.0 0 24

Index Scan using c_payment_pkey on public.c_payment p_3 (cost=0.42..2.20 rows=1 width=6) (actual time=0.013..0.013 rows=0 loops=24)

  • Output: p_3.c_payment_id, p_3.ad_client_id, p_3.ad_org_id, p_3.isactive, p_3.created, p_3.createdby, p_3.updated, p_3.updatedby, p_3.documentno, p_3.datetrx, p_3.isreceipt, p_3.c_doctype_id, p_3.trxtype, p_3.c_bankaccount_id, p_3.c_bpartner_id, p_3.c_invoice_id, p_3.c_bp_bankaccount_id, p_3.c_paymentbatch_id, p_3.tendertype, p_3.creditcardtype, p_3.creditcardnumber, p_3.creditcardvv, p_3.creditcardexpmm, p_3.creditcardexpyy, p_3.micr, p_3.routingno, p_3.accountno, p_3.checkno, p_3.a_name, p_3.a_street, p_3.a_city, p_3.a_state, p_3.a_zip, p_3.a_ident_dl, p_3.a_ident_ssn, p_3.a_email, p_3.voiceauthcode, p_3.orig_trxid, p_3.ponum, p_3.c_currency_id, p_3.payamt, p_3.discountamt, p_3.writeoffamt, p_3.taxamt, p_3.isapproved, p_3.r_pnref, p_3.r_result, p_3.r_respmsg, p_3.r_authcode, p_3.r_avsaddr, p_3.r_avszip, p_3.r_info, p_3.processing, p_3.oprocessing, p_3.docstatus, p_3.docaction, p_3.isreconciled, p_3.isallocated, p_3.isonline, p_3.processed, p_3.posted, p_3.isoverunderpayment, p_3.overunderamt, p_3.a_country, p_3.c_project_id, p_3.isselfservice, p_3.chargeamt, p_3.c_charge_id, p_3.isdelayedcapture, p_3.r_authcode_dc, p_3.r_cvv2match, p_3.r_pnref_dc, p_3.swipe, p_3.ad_orgtrx_id, p_3.c_campaign_id, p_3.c_activity_id, p_3.user1_id, p_3.user2_id, p_3.c_conversiontype_id, p_3.description, p_3.dateacct, p_3.c_order_id, p_3.isprepayment, p_3.exme_ctapac_id, p_3.recibono, p_3.ref_payment_id, p_3.reversal_id, p_3.c_cashbook_id, p_3.verpoliza, p_3.exme_citamedica_id, p_3.payconcept, p_3.exme_adjustmenttype_id, p_3.paymenttype, p_3.beginningbalance, p_3.endingbalance, p_3.amount, p_3.exme_paciente_id, p_3.exme_claimpayment_id, p_3.conftype, p_3.creditmemo, p_3.backoffice, p_3.exme_partidapres_id, p_3.ref_invoice_id, p_3.type, p_3.amtsubtract, p_3.rate, p_3.c_bank_id, p_3.name, p_3.c_bankreciving_id, p_3.receivingbankacct, p_3.taxid, p_3.typeacct, p_3.amtcheckdeposited, p_3.amtcheck, p_3.exme_methodpaymentcode_id, p_3.exme_formapago_id, p_3.versionno, p_3.isdevol, p_3.isconsolid
  • Index Cond: (p_3.c_payment_id = al_3.c_payment_id)
  • Filter: ((p_3.exme_ctapac_id IS NULL) OR (p_3.type = 'R'::bpchar))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=77 read=19
229. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype dt_6 (cost=0.29..0.36 rows=1 width=6) (never executed)

  • Output: dt_6.c_doctype_id, dt_6.ad_client_id, dt_6.ad_org_id, dt_6.isactive, dt_6.created, dt_6.createdby, dt_6.updated, dt_6.updatedby, dt_6.name, dt_6.printname, dt_6.description, dt_6.docbasetype, dt_6.issotrx, dt_6.docsubtypeso, dt_6.hasproforma, dt_6.c_doctypeproforma_id, dt_6.c_doctypeshipment_id, dt_6.c_doctypeinvoice_id, dt_6.isdocnocontrolled, dt_6.docnosequence_id, dt_6.gl_category_id, dt_6.hascharges, dt_6.documentnote, dt_6.isdefault, dt_6.documentcopies, dt_6.ad_printformat_id, dt_6.isdefaultcounterdoc, dt_6.isshipconfirm, dt_6.ispickqaconfirm, dt_6.isintransit, dt_6.issplitwhendifference, dt_6.c_doctypedifference_id, dt_6.iscreatecounter, dt_6.isindexed, dt_6.definitesequence_id, dt_6.isoverwriteseqoncomplete, dt_6.isoverwritedateoncomplete, dt_6.exme_typevouchercode_id, dt_6.exme_relationtypecode_id, dt_6.type
  • Index Cond: (dt_6.c_doctype_id = i_3.c_doctype_id)
  • Filter: (((dt_6.docsubtypeso IS NULL) OR (dt_6.docsubtypeso = 'SR'::bpchar)) AND (dt_6.isactive = 'Y'::bpchar) AND (dt_6.docbasetype = 'ARI'::bpchar))
230. 0.000 201.934 ↓ 0.0 0 1

Nested Loop (cost=126,430.17..126,446.26 rows=1 width=45) (actual time=201.934..201.934 rows=0 loops=1)

  • Output: al_4.c_invoice_id, ((al_4.amount + al_4.discountamt) + al_4.writeoffamt), i_4.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=64531
231.          

Initplan (forNested Loop)

232. 0.005 0.005 ↑ 1.0 1 1

CTE Scan on params params_23 (cost=0.00..0.02 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=1)

  • Output: params_23.org_id
233. 0.007 0.007 ↑ 1.0 1 1

CTE Scan on params params_24 (cost=0.00..0.02 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=1)

  • Output: params_24.org_id
234. 0.053 201.925 ↓ 0.0 0 1

Nested Loop (cost=126,429.85..126,445.86 rows=1 width=31) (actual time=201.925..201.925 rows=0 loops=1)

  • Output: al_4.c_invoice_id, al_4.amount, al_4.discountamt, al_4.writeoffamt, i_4.exme_ctapac_id, i_4.c_doctype_id
  • Inner Unique: true
  • Buffers: shared hit=64531
235. 0.060 201.872 ↓ 24.0 24 1

Nested Loop (cost=126,429.42..126,443.24 rows=1 width=38) (actual time=201.442..201.872 rows=24 loops=1)

  • Output: al_4.c_invoice_id, al_4.amount, al_4.discountamt, al_4.writeoffamt, al_4.c_cashline_id, i_4.exme_ctapac_id, i_4.c_doctype_id
  • Buffers: shared hit=64531
236. 0.079 201.668 ↓ 16.0 16 1

Nested Loop (cost=126,428.99..126,437.04 rows=1 width=19) (actual time=201.361..201.668 rows=16 loops=1)

  • Output: i_4.exme_ctapac_id, i_4.c_invoice_id, i_4.c_doctype_id
  • Buffers: shared hit=64460
237. 0.071 0.133 ↓ 48.0 48 1

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual time=0.115..0.133 rows=48 loops=1)

  • Output: pac_2.exme_ctapac_id
  • Group Key: pac_2.exme_ctapac_id
238. 0.062 0.062 ↓ 48.0 48 1

CTE Scan on pacientes pac_2 (cost=0.00..0.02 rows=1 width=16) (actual time=0.027..0.062 rows=48 loops=1)

  • Output: pac_2.exme_ctapac_id, pac_2.mrn, pac_2.encounter, pac_2.nombre_pac, pac_2.gender, pac_2.birth_date, pac_2.age_at_admission, pac_2.room, pac_2.bed, pac_2.tipopac, pac_2.physician, pac_2.specialty, pac_2.admission_diagnosis, pac_2.admission_diagnosis_trunk, pac_2.patient_type, pac_2.service_unit, pac_2.dateordered, pac_2.admit_date, pac_2.discharge_date, pac_2.los, pac_2.institucion, pac_2.fecha_prealta, pac_2.prealta, pac_2.destino
239. 31.471 201.456 ↓ 0.0 0 48

Index Scan using ender_c_invoice_ctapac on public.c_invoice i_4 (cost=126,428.97..126,437.00 rows=1 width=19) (actual time=4.196..4.197 rows=0 loops=48)

  • Output: i_4.c_invoice_id, i_4.ad_client_id, i_4.ad_org_id, i_4.isactive, i_4.created, i_4.createdby, i_4.updated, i_4.updatedby, i_4.issotrx, i_4.documentno, i_4.docstatus, i_4.docaction, i_4.processing, i_4.processed, i_4.posted, i_4.c_doctype_id, i_4.c_doctypetarget_id, i_4.c_order_id, i_4.description, i_4.isapproved, i_4.istransferred, i_4.isprinted, i_4.salesrep_id, i_4.dateinvoiced, i_4.dateprinted, i_4.dateacct, i_4.c_bpartner_id, i_4.c_bpartner_location_id, i_4.poreference, i_4.isdiscountprinted, i_4.dateordered, i_4.c_currency_id, i_4.paymentrule, i_4.c_paymentterm_id, i_4.c_charge_id, i_4.chargeamt, i_4.totallines, i_4.grandtotal, i_4.m_pricelist_id, i_4.istaxincluded, i_4.c_campaign_id, i_4.c_project_id, i_4.c_activity_id, i_4.ispaid, i_4.c_payment_id, i_4.c_cashline_id, i_4.createfrom, i_4.generateto, i_4.sendemail, i_4.ad_user_id, i_4.copyfrom, i_4.isselfservice, i_4.ad_orgtrx_id, i_4.user1_id, i_4.user2_id, i_4.c_conversiontype_id, i_4.ispayschedulevalid, i_4.ref_invoice_id, i_4.isindispute, i_4.exme_ctapacext_id, i_4.descfromaseg, i_4.precfromaseg, i_4.documentnoext, i_4.afecta_caja, i_4.c_cashbook_id, i_4.discountporcent, i_4.discountamt, i_4.address1, i_4.address2, i_4.city, i_4.postal, i_4.c_country_id, i_4.c_region_id, i_4.address3, i_4.exme_paciente_id, i_4.exme_medico_id, i_4.nombre_medico, i_4.nombre_paciente, i_4.exme_estserv_id, i_4.c_cash_id, i_4.canceledby, i_4.motivocancel, i_4.exme_motivocancel_id, i_4.isprintedpre, i_4.updatedbycancel, i_4.numext, i_4.numin, i_4.sexo, i_4.fechanac, i_4.invoicephone, i_4.exme_towncouncil_id, i_4.tipooperacion, i_4.observation, i_4.dunninggrace, i_4.m_rma_id, i_4.c_dunninglevel_id, i_4.invoicecollectiontype, i_4.reversal_id, i_4.verpoliza, i_4.isgenerated, i_4.globaldiscount, i_4.sello, i_4.cadena, i_4.exme_ctapac_id, i_4.conftype, i_4.multiple_id, i_4.ismultiple, i_4.partner, i_4.uuid, i_4.estserv, i_4.prepayment, i_4.backoffice, i_4.discounttaxamt, i_4.taxamt, i_4.exme_claimpayment_id, i_4.coaseguro, i_4.deducible, i_4.coaseguromed, i_4.copago, i_4.coaseguroamt, i_4.deducibleamt, i_4.coaseguromedamt, i_4.copagoamt, i_4.ref_invoice_sales_id, i_4.isinvoiced, i_4.isorderfaclinecategory, i_4.trxtype, i_4.rebate, i_4.sortby, i_4.addenda, i_4.sellosat, i_4.certificadosat, i_4.nocertificado, i_4.certificado, i_4.rate, i_4.m_inout_id, i_4.generatedfrom, i_4.typeacct, i_4.detailpayment, i_4.c_cash_cancel_id, i_4.datecanceled, i_4.exme_areacaja_id, i_4.accountno, i_4.post, i_4.statusuuid, i_4.canceldescription, i_4.versionno, i_4.emprelationship, i_4.perception, i_4.comp_ditto, i_4.perceptioniva, i_4.afip, i_4.date_comp, i_4.typefac_ditto
  • Index Cond: ((i_4.exme_ctapac_id = pac_2.exme_ctapac_id) AND (i_4.isactive = 'Y'::bpchar) AND (i_4.ad_org_id = $81))
  • Filter: ((NOT (hashed SubPlan 44)) AND (i_4.issotrx = 'Y'::bpchar) AND (i_4.docstatus = ANY ('{DR,CO,IP,CL}'::bpchar[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=64460
240.          

SubPlan (forIndex Scan)

241. 9.066 169.985 ↓ 116.4 59,695 1

Nested Loop (cost=0.56..126,427.25 rows=513 width=7) (actual time=0.137..169.985 rows=59,695 loops=1)

  • Output: ssi_3.ref_invoice_id
  • Buffers: shared hit=64297
242. 2.735 2.735 ↓ 1.6 169 1

Seq Scan on public.c_doctype dt_5 (cost=0.00..347.14 rows=104 width=6) (actual time=0.038..2.735 rows=169 loops=1)

  • Output: dt_5.c_doctype_id, dt_5.ad_client_id, dt_5.ad_org_id, dt_5.isactive, dt_5.created, dt_5.createdby, dt_5.updated, dt_5.updatedby, dt_5.name, dt_5.printname, dt_5.description, dt_5.docbasetype, dt_5.issotrx, dt_5.docsubtypeso, dt_5.hasproforma, dt_5.c_doctypeproforma_id, dt_5.c_doctypeshipment_id, dt_5.c_doctypeinvoice_id, dt_5.isdocnocontrolled, dt_5.docnosequence_id, dt_5.gl_category_id, dt_5.hascharges, dt_5.documentnote, dt_5.isdefault, dt_5.documentcopies, dt_5.ad_printformat_id, dt_5.isdefaultcounterdoc, dt_5.isshipconfirm, dt_5.ispickqaconfirm, dt_5.isintransit, dt_5.issplitwhendifference, dt_5.c_doctypedifference_id, dt_5.iscreatecounter, dt_5.isindexed, dt_5.definitesequence_id, dt_5.isoverwriteseqoncomplete, dt_5.isoverwritedateoncomplete, dt_5.exme_typevouchercode_id, dt_5.exme_relationtypecode_id, dt_5.type
  • Filter: ((dt_5.docsubtypeso IS NULL) AND (dt_5.isactive = 'Y'::bpchar) AND (dt_5.docbasetype = 'ARC'::bpchar))
  • Rows Removed by Filter: 9174
  • Buffers: shared hit=207
243. 158.184 158.184 ↓ 1.5 353 169

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_3 (cost=0.56..1,209.92 rows=239 width=13) (actual time=0.037..0.936 rows=353 loops=169)

  • Output: ssi_3.isactive, ssi_3.c_doctype_id, ssi_3.docstatus, ssi_3.issotrx, ssi_3.c_invoice_id, ssi_3.ref_invoice_id, ssi_3.trxtype, ssi_3.issotrx
  • Index Cond: ((ssi_3.isactive = 'Y'::bpchar) AND (ssi_3.c_doctype_id = dt_5.c_doctype_id) AND (ssi_3.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_3.issotrx = 'Y'::bpchar) AND (ssi_3.trxtype = ANY ('{N,X}'::bpchar[])))
  • Heap Fetches: 59695
  • Buffers: shared hit=64090
244. 0.144 0.144 ↓ 2.0 2 16

Index Scan using c_allocationline_invoice on public.c_allocationline al_4 (cost=0.43..6.19 rows=1 width=25) (actual time=0.008..0.009 rows=2 loops=16)

  • Output: al_4.c_allocationline_id, al_4.ad_client_id, al_4.ad_org_id, al_4.isactive, al_4.created, al_4.createdby, al_4.updated, al_4.updatedby, al_4.allocationno, al_4.datetrx, al_4.ismanual, al_4.c_invoice_id, al_4.c_bpartner_id, al_4.c_order_id, al_4.c_payment_id, al_4.c_cashline_id, al_4.amount, al_4.discountamt, al_4.writeoffamt, al_4.posted, al_4.overunderamt, al_4.c_allocationhdr_id, al_4.c_charge_id, al_4.amtacct, al_4.creditmemo, al_4.c_payselectionline_id, al_4.rate, al_4.gain, al_4.amtbadge, al_4.typeacct, al_4.exme_paymentelectronic_id, al_4.ref_invoice_id
  • Index Cond: (al_4.c_invoice_id = i_4.c_invoice_id)
  • Filter: ((al_4.isactive = 'Y'::bpchar) AND (al_4.ad_org_id = $84))
  • Buffers: shared hit=71
245. 0.000 0.000 ↓ 0.0 0 24

Index Scan using c_cashline_pkey on public.c_cashline c_2 (cost=0.43..2.62 rows=1 width=6) (actual time=0.000..0.000 rows=0 loops=24)

  • Output: c_2.c_cashline_id, c_2.ad_client_id, c_2.ad_org_id, c_2.isactive, c_2.created, c_2.createdby, c_2.updated, c_2.updatedby, c_2.c_cash_id, c_2.line, c_2.description, c_2.cashtype, c_2.c_bankaccount_id, c_2.c_charge_id, c_2.c_invoice_id, c_2.c_currency_id, c_2.amount, c_2.discountamt, c_2.writeoffamt, c_2.isgenerated, c_2.processed, c_2.c_payment_id, c_2.exme_ctapac_id, c_2.exme_formapago_id, c_2.creditcardtype, c_2.creditcardnumber, c_2.creditcardvv, c_2.creditcardexpmm, c_2.creditcardexpyy, c_2.accountno, c_2.checkno, c_2.routingno, c_2.micr, c_2.isprepayment, c_2.a_name, c_2.recibono, c_2.cambio, c_2.exme_citamedica_id, c_2.iscancelled, c_2.ref_cash_id, c_2.typeacct, c_2.ref_cashline_id, c_2.exme_methodpaymentcode_id, c_2.rate
  • Index Cond: (c_2.c_cashline_id = al_4.c_cashline_id)
  • Filter: (c_2.exme_ctapac_id IS NULL)
246. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype dt_7 (cost=0.29..0.36 rows=1 width=6) (never executed)

  • Output: dt_7.c_doctype_id, dt_7.ad_client_id, dt_7.ad_org_id, dt_7.isactive, dt_7.created, dt_7.createdby, dt_7.updated, dt_7.updatedby, dt_7.name, dt_7.printname, dt_7.description, dt_7.docbasetype, dt_7.issotrx, dt_7.docsubtypeso, dt_7.hasproforma, dt_7.c_doctypeproforma_id, dt_7.c_doctypeshipment_id, dt_7.c_doctypeinvoice_id, dt_7.isdocnocontrolled, dt_7.docnosequence_id, dt_7.gl_category_id, dt_7.hascharges, dt_7.documentnote, dt_7.isdefault, dt_7.documentcopies, dt_7.ad_printformat_id, dt_7.isdefaultcounterdoc, dt_7.isshipconfirm, dt_7.ispickqaconfirm, dt_7.isintransit, dt_7.issplitwhendifference, dt_7.c_doctypedifference_id, dt_7.iscreatecounter, dt_7.isindexed, dt_7.definitesequence_id, dt_7.isoverwriteseqoncomplete, dt_7.isoverwritedateoncomplete, dt_7.exme_typevouchercode_id, dt_7.exme_relationtypecode_id, dt_7.type
  • Index Cond: (dt_7.c_doctype_id = i_4.c_doctype_id)
  • Filter: ((dt_7.docsubtypeso IS NULL) AND (dt_7.isactive = 'Y'::bpchar) AND (dt_7.docbasetype = 'ARI'::bpchar))
247. 0.000 49.453 ↓ 0.0 0 1

Nested Loop (cost=248.55..31,221.27 rows=1 width=19) (actual time=49.453..49.453 rows=0 loops=1)

  • Output: i_5.c_invoice_id, i_5.grandtotal, i_5.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=19495
248.          

Initplan (forNested Loop)

249. 0.009 0.009 ↑ 1.0 1 1

CTE Scan on params params_25 (cost=0.00..0.02 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=1)

  • Output: params_25.org_id
250. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on params params_26 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: params_26.org_id
251. 0.100 49.438 ↓ 0.0 0 1

Nested Loop (cost=248.22..31,219.56 rows=1 width=25) (actual time=49.438..49.438 rows=0 loops=1)

  • Output: i_5.c_invoice_id, i_5.grandtotal, i_5.exme_ctapac_id, i_5.c_doctype_id
  • Buffers: shared hit=19495
252. 43.091 48.954 ↑ 1.4 48 1

Bitmap Heap Scan on public.exme_ctapac cpac_2 (cost=247.79..30,660.38 rows=66 width=6) (actual time=16.029..48.954 rows=48 loops=1)

  • Output: cpac_2.exme_ctapac_id, cpac_2.ad_client_id, cpac_2.ad_org_id, cpac_2.isactive, cpac_2.created, cpac_2.createdby, cpac_2.updated, cpac_2.updatedby, cpac_2.documentno, cpac_2.docstatus, cpac_2.docaction, cpac_2.processing, cpac_2.processed, cpac_2.c_doctype_id, cpac_2.c_doctypetarget_id, cpac_2.description, cpac_2.isapproved, cpac_2.iscreditapproved, cpac_2.isinvoiced, cpac_2.isprinted, cpac_2.dateordered, cpac_2.dateprinted, cpac_2.dateacct, cpac_2.priorityrule, cpac_2.grandtotal, cpac_2.m_pricelist_id, cpac_2.c_campaign_id, cpac_2.c_project_id, cpac_2.c_activity_id, cpac_2.ad_user_id, cpac_2.ad_orgtrx_id, cpac_2.user1_id, cpac_2.user2_id, cpac_2.fechacancel, cpac_2.exme_paciente_id, cpac_2.exme_especialidad_id, cpac_2.exme_motivocita_id, cpac_2.estatus, cpac_2.exme_medico_id, cpac_2.ref_ctapac_id, cpac_2.c_currency_id, cpac_2.ad_printformat_id, cpac_2.impcontrato, cpac_2.impconsent, cpac_2.impdatos, cpac_2.impbrazalete, cpac_2.exme_diagnostico_id, cpac_2.exme_cama_id, cpac_2.tipoarea, cpac_2.fechacargodiario, cpac_2.fechacierre, cpac_2.exme_paqbase_version_id, cpac_2.exme_ctapacext_id, cpac_2.exme_estserv_id, cpac_2.isuso, cpac_2.isbloqueada, cpac_2.isautorizada, cpac_2.diagnostico_ingreso, cpac_2.fechaalta, cpac_2.actualizadoalta, cpac_2.statusalta, cpac_2.exme_camaing_id, cpac_2.fechaprealta, cpac_2.actualizadoprealta, cpac_2.isfactespec, cpac_2.ref_ctapacfam_id, cpac_2.exme_descpreciofijo_id, cpac_2.tiposangre, cpac_2.exme_tipotrasplante_id, cpac_2.exme_motivoegreso_id, cpac_2.casosmedicos, cpac_2.exme_estserving_id, cpac_2.fechatraslado, cpac_2.exme_procedencia_id, cpac_2.isgenerated, cpac_2.statuseleg, cpac_2.instruccionalta, cpac_2.nombrearchivo, cpac_2.formatoarchivo, cpac_2.archivo, cpac_2.informealta, cpac_2.exme_medico2_id, cpac_2.exme_especialidad2_id, cpac_2.exme_dischargestatus_id, cpac_2.resstatus, cpac_2.billingstatus, cpac_2.exme_tipoprod_id, cpac_2.drg, cpac_2.exme_tipopaciente_id, cpac_2.exme_arrivalmode_id, cpac_2.exme_admittype_id, cpac_2.exme_admitsource_id, cpac_2.isnewborn, cpac_2.exme_beneficiosh_id, cpac_2.exme_estservprov_id, cpac_2.billdate, cpac_2.exme_area_id, cpac_2.ref_unit_id, cpac_2.encounterstatus, cpac_2.exme_medicorefer_id, cpac_2.exme_especialidadrefer_id, cpac_2.exme_ctapacrefer_id, cpac_2.isidentifier, cpac_2.email, cpac_2.requester, cpac_2.fechaenv, cpac_2.departuredate, cpac_2.exme_pos_id, cpac_2.exme_drg_id, cpac_2.noinsurancecoverage, cpac_2.nostatementage, cpac_2.validonqueue, cpac_2.exme_accompaniedby_id, cpac_2.exme_transport_mode_id, cpac_2.exme_discharged_via_id, cpac_2.comments, cpac_2.exme_institucion_id, cpac_2.billingtype, cpac_2.coded, cpac_2.codingdate, cpac_2.codedprof, cpac_2.codingdateprof, cpac_2.institutionalstatus, cpac_2.institutionalstep, cpac_2.isvalid, cpac_2.nombre_pac, cpac_2.mrn, cpac_2.processingpaq, cpac_2.processingpaq2, cpac_2.isclosed, cpac_2.exme_eventmerge_id, cpac_2.fallrisk, cpac_2.triage, cpac_2.apollo_policy, cpac_2.apollo_claim
  • Recheck Cond: (cpac_2.ad_org_id = $85)
  • Filter: ((COALESCE(cpac_2.fechaalta, cpac_2.fechacierre) IS NULL) AND (cpac_2.fechacancel IS NULL) AND (cpac_2.isactive = 'Y'::bpchar) AND ((cpac_2.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 26064
  • Heap Blocks: exact=19258
  • Buffers: shared hit=19332
253. 5.863 5.863 ↓ 2.0 26,112 1

Bitmap Index Scan on ender_exme_ctapac_active_client_org (cost=0.00..247.78 rows=13,247 width=0) (actual time=5.862..5.863 rows=26,112 loops=1)

  • Index Cond: (cpac_2.ad_org_id = $85)
  • Buffers: shared hit=74
254. 0.384 0.384 ↓ 0.0 0 48

Index Scan using ender_c_invoice_ctapac on public.c_invoice i_5 (cost=0.43..8.46 rows=1 width=25) (actual time=0.008..0.008 rows=0 loops=48)

  • Output: i_5.c_invoice_id, i_5.ad_client_id, i_5.ad_org_id, i_5.isactive, i_5.created, i_5.createdby, i_5.updated, i_5.updatedby, i_5.issotrx, i_5.documentno, i_5.docstatus, i_5.docaction, i_5.processing, i_5.processed, i_5.posted, i_5.c_doctype_id, i_5.c_doctypetarget_id, i_5.c_order_id, i_5.description, i_5.isapproved, i_5.istransferred, i_5.isprinted, i_5.salesrep_id, i_5.dateinvoiced, i_5.dateprinted, i_5.dateacct, i_5.c_bpartner_id, i_5.c_bpartner_location_id, i_5.poreference, i_5.isdiscountprinted, i_5.dateordered, i_5.c_currency_id, i_5.paymentrule, i_5.c_paymentterm_id, i_5.c_charge_id, i_5.chargeamt, i_5.totallines, i_5.grandtotal, i_5.m_pricelist_id, i_5.istaxincluded, i_5.c_campaign_id, i_5.c_project_id, i_5.c_activity_id, i_5.ispaid, i_5.c_payment_id, i_5.c_cashline_id, i_5.createfrom, i_5.generateto, i_5.sendemail, i_5.ad_user_id, i_5.copyfrom, i_5.isselfservice, i_5.ad_orgtrx_id, i_5.user1_id, i_5.user2_id, i_5.c_conversiontype_id, i_5.ispayschedulevalid, i_5.ref_invoice_id, i_5.isindispute, i_5.exme_ctapacext_id, i_5.descfromaseg, i_5.precfromaseg, i_5.documentnoext, i_5.afecta_caja, i_5.c_cashbook_id, i_5.discountporcent, i_5.discountamt, i_5.address1, i_5.address2, i_5.city, i_5.postal, i_5.c_country_id, i_5.c_region_id, i_5.address3, i_5.exme_paciente_id, i_5.exme_medico_id, i_5.nombre_medico, i_5.nombre_paciente, i_5.exme_estserv_id, i_5.c_cash_id, i_5.canceledby, i_5.motivocancel, i_5.exme_motivocancel_id, i_5.isprintedpre, i_5.updatedbycancel, i_5.numext, i_5.numin, i_5.sexo, i_5.fechanac, i_5.invoicephone, i_5.exme_towncouncil_id, i_5.tipooperacion, i_5.observation, i_5.dunninggrace, i_5.m_rma_id, i_5.c_dunninglevel_id, i_5.invoicecollectiontype, i_5.reversal_id, i_5.verpoliza, i_5.isgenerated, i_5.globaldiscount, i_5.sello, i_5.cadena, i_5.exme_ctapac_id, i_5.conftype, i_5.multiple_id, i_5.ismultiple, i_5.partner, i_5.uuid, i_5.estserv, i_5.prepayment, i_5.backoffice, i_5.discounttaxamt, i_5.taxamt, i_5.exme_claimpayment_id, i_5.coaseguro, i_5.deducible, i_5.coaseguromed, i_5.copago, i_5.coaseguroamt, i_5.deducibleamt, i_5.coaseguromedamt, i_5.copagoamt, i_5.ref_invoice_sales_id, i_5.isinvoiced, i_5.isorderfaclinecategory, i_5.trxtype, i_5.rebate, i_5.sortby, i_5.addenda, i_5.sellosat, i_5.certificadosat, i_5.nocertificado, i_5.certificado, i_5.rate, i_5.m_inout_id, i_5.generatedfrom, i_5.typeacct, i_5.detailpayment, i_5.c_cash_cancel_id, i_5.datecanceled, i_5.exme_areacaja_id, i_5.accountno, i_5.post, i_5.statusuuid, i_5.canceldescription, i_5.versionno, i_5.emprelationship, i_5.perception, i_5.comp_ditto, i_5.perceptioniva, i_5.afip, i_5.date_comp, i_5.typefac_ditto
  • Index Cond: ((i_5.exme_ctapac_id = cpac_2.exme_ctapac_id) AND (i_5.isactive = 'Y'::bpchar) AND (i_5.ad_org_id = $86))
  • Filter: ((i_5.issotrx = 'Y'::bpchar) AND (i_5.trxtype = 'P'::bpchar) AND (i_5.docstatus = ANY ('{DR,CO,IP,CL}'::bpchar[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=163
255. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype dt_8 (cost=0.29..1.64 rows=1 width=6) (never executed)

  • Output: dt_8.c_doctype_id, dt_8.ad_client_id, dt_8.ad_org_id, dt_8.isactive, dt_8.created, dt_8.createdby, dt_8.updated, dt_8.updatedby, dt_8.name, dt_8.printname, dt_8.description, dt_8.docbasetype, dt_8.issotrx, dt_8.docsubtypeso, dt_8.hasproforma, dt_8.c_doctypeproforma_id, dt_8.c_doctypeshipment_id, dt_8.c_doctypeinvoice_id, dt_8.isdocnocontrolled, dt_8.docnosequence_id, dt_8.gl_category_id, dt_8.hascharges, dt_8.documentnote, dt_8.isdefault, dt_8.documentcopies, dt_8.ad_printformat_id, dt_8.isdefaultcounterdoc, dt_8.isshipconfirm, dt_8.ispickqaconfirm, dt_8.isintransit, dt_8.issplitwhendifference, dt_8.c_doctypedifference_id, dt_8.iscreatecounter, dt_8.isindexed, dt_8.definitesequence_id, dt_8.isoverwriteseqoncomplete, dt_8.isoverwritedateoncomplete, dt_8.exme_typevouchercode_id, dt_8.exme_relationtypecode_id, dt_8.type
  • Index Cond: (dt_8.c_doctype_id = i_5.c_doctype_id)
  • Filter: ((dt_8.docsubtypeso IS NULL) AND (dt_8.isactive = 'Y'::bpchar) AND (dt_8.docbasetype = 'ARC'::bpchar))
256. 0.030 962.969 ↓ 0.0 0 1

WindowAgg (cost=0.12..0.19 rows=4 width=48) (actual time=962.969..962.969 rows=0 loops=1)

  • Output: p_4.exme_ctapac_id, sum(p_4.pago) OVER (?)
  • Buffers: shared hit=156297 read=54239
257. 0.031 962.939 ↓ 0.0 0 1

Sort (cost=0.12..0.13 rows=4 width=48) (actual time=962.939..962.939 rows=0 loops=1)

  • Output: p_4.exme_ctapac_id, p_4.pago
  • Sort Key: p_4.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=156297 read=54239
258. 962.908 962.908 ↓ 0.0 0 1

CTE Scan on pagoe p_4 (cost=0.00..0.08 rows=4 width=48) (actual time=962.907..962.908 rows=0 loops=1)

  • Output: p_4.exme_ctapac_id, p_4.pago
  • Buffers: shared hit=156297 read=54239
259.          

CTE cxc2

260. 0.009 1,626.562 ↓ 0.0 0 1

Unique (cost=280,733.43..280,733.45 rows=1 width=112) (actual time=1,626.562..1,626.562 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, (((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))), ((cxc_1.amount - ((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))))
  • Buffers: shared hit=365417 read=229394
261.          

CTE cxc

262. 0.019 1,626.418 ↓ 0.0 0 1

GroupAggregate (cost=100,916.58..100,924.67 rows=1 width=38) (actual time=1,626.418..1,626.418 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, sum(cashline.amount)
  • Group Key: cta.exme_ctapac_id
  • Buffers: shared hit=365417 read=229394
263. 0.009 1,626.399 ↓ 0.0 0 1

Nested Loop Semi Join (cost=100,916.58..100,924.66 rows=1 width=12) (actual time=1,626.399..1,626.399 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, cashline.amount
  • Join Filter: (cta.exme_ctapac_id = pac_3.exme_ctapac_id)
  • Buffers: shared hit=365417 read=229394
264. 0.009 1,626.390 ↓ 0.0 0 1

Nested Loop (cost=100,916.58..100,924.62 rows=1 width=12) (actual time=1,626.390..1,626.390 rows=0 loops=1)

  • Output: cashline.amount, cta.exme_ctapac_id
  • Inner Unique: true
  • Buffers: shared hit=365417 read=229394
265. 0.000 1,626.381 ↓ 0.0 0 1

Unique (cost=100,916.16..100,916.17 rows=1 width=44) (actual time=1,626.380..1,626.381 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, (min(cline.c_cashline_id) OVER (?))
  • Buffers: shared hit=365417 read=229394
266.          

Initplan (forUnique)

267. 0.006 0.006 ↑ 1.0 1 1

CTE Scan on params params_27 (cost=0.00..0.02 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: params_27.org_id
268. 0.008 0.008 ↑ 1.0 1 1

CTE Scan on params params_28 (cost=0.00..0.02 rows=1 width=32) (actual time=0.008..0.008 rows=1 loops=1)

  • Output: params_28.client_id
269. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params params_29 (cost=0.00..0.02 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=1)

  • Output: params_29.org_id
270. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on params params_30 (cost=0.00..0.02 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=1)

  • Output: params_30.org_id
271. 0.016 1,626.375 ↓ 0.0 0 1

Sort (cost=100,916.08..100,916.08 rows=1 width=44) (actual time=1,626.375..1,626.375 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, (min(cline.c_cashline_id) OVER (?))
  • Sort Key: cta.exme_ctapac_id, rem.c_invoice_id, (min(cline.c_cashline_id) OVER (?))
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=365417 read=229394
272. 0.028 1,626.359 ↓ 0.0 0 1

WindowAgg (cost=100,916.04..100,916.07 rows=1 width=44) (actual time=1,626.359..1,626.359 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, min(cline.c_cashline_id) OVER (?)
  • Buffers: shared hit=365417 read=229394
273. 0.012 1,626.331 ↓ 0.0 0 1

Sort (cost=100,916.04..100,916.05 rows=1 width=18) (actual time=1,626.331..1,626.331 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, cline.c_cashline_id
  • Sort Key: cta.exme_ctapac_id, rem.c_invoice_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=365417 read=229394
274. 0.037 1,626.319 ↓ 0.0 0 1

Result (cost=90,924.04..100,916.03 rows=1 width=18) (actual time=1,626.319..1,626.319 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, cline.c_cashline_id
  • One-Time Filter: ($103 = $107)
  • Buffers: shared hit=365417 read=229394
275. 0.049 1,626.282 ↓ 0.0 0 1

Nested Loop (cost=90,924.04..100,916.03 rows=1 width=18) (actual time=1,626.282..1,626.282 rows=0 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, cline.c_cashline_id
  • Buffers: shared hit=365417 read=229394
276. 0.073 1,626.097 ↓ 8.0 8 1

Nested Loop (cost=90,923.61..100,915.42 rows=1 width=18) (actual time=1,384.656..1,626.097 rows=8 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, si_1.ref_invoice_sales_id
  • Inner Unique: true
  • Buffers: shared hit=365406 read=229381
277. 0.000 1,625.952 ↓ 8.0 8 1

Nested Loop (cost=90,923.33..100,915.10 rows=1 width=24) (actual time=1,384.576..1,625.952 rows=8 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id, si_1.c_doctype_id, si_1.ref_invoice_sales_id
  • Buffers: shared hit=365382 read=229381
278. 0.000 1,288.854 ↓ 19.0 19 1

Gather (cost=1,040.15..11,024.20 rows=1 width=12) (actual time=1,042.524..1,288.854 rows=19 loops=1)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id
  • Workers Planned: 1
  • Params Evaluated: $106, $107, $108
  • Workers Launched: 1
  • Buffers: shared hit=343258 read=189802
279. 437.844 1,439.002 ↓ 10.0 10 2

Nested Loop (cost=40.15..10,024.10 rows=1 width=12) (actual time=1,037.724..1,439.002 rows=10 loops=2)

  • Output: cta.exme_ctapac_id, rem.c_invoice_id
  • Inner Unique: true
  • Buffers: shared hit=343258 read=189802
  • Worker 0: actual time=1040.697..1603.712 rows=10 loops=1
  • Buffers: shared hit=182118 read=97595
280. 852.395 1,001.156 ↓ 238.8 168,326 2

Parallel Bitmap Heap Scan on public.c_invoice rem (cost=39.73..4,619.94 rows=705 width=13) (actual time=157.885..1,001.156 rows=168,326 loops=2)

  • Output: rem.c_invoice_id, rem.ad_client_id, rem.ad_org_id, rem.isactive, rem.created, rem.createdby, rem.updated, rem.updatedby, rem.issotrx, rem.documentno, rem.docstatus, rem.docaction, rem.processing, rem.processed, rem.posted, rem.c_doctype_id, rem.c_doctypetarget_id, rem.c_order_id, rem.description, rem.isapproved, rem.istransferred, rem.isprinted, rem.salesrep_id, rem.dateinvoiced, rem.dateprinted, rem.dateacct, rem.c_bpartner_id, rem.c_bpartner_location_id, rem.poreference, rem.isdiscountprinted, rem.dateordered, rem.c_currency_id, rem.paymentrule, rem.c_paymentterm_id, rem.c_charge_id, rem.chargeamt, rem.totallines, rem.grandtotal, rem.m_pricelist_id, rem.istaxincluded, rem.c_campaign_id, rem.c_project_id, rem.c_activity_id, rem.ispaid, rem.c_payment_id, rem.c_cashline_id, rem.createfrom, rem.generateto, rem.sendemail, rem.ad_user_id, rem.copyfrom, rem.isselfservice, rem.ad_orgtrx_id, rem.user1_id, rem.user2_id, rem.c_conversiontype_id, rem.ispayschedulevalid, rem.ref_invoice_id, rem.isindispute, rem.exme_ctapacext_id, rem.descfromaseg, rem.precfromaseg, rem.documentnoext, rem.afecta_caja, rem.c_cashbook_id, rem.discountporcent, rem.discountamt, rem.address1, rem.address2, rem.city, rem.postal, rem.c_country_id, rem.c_region_id, rem.address3, rem.exme_paciente_id, rem.exme_medico_id, rem.nombre_medico, rem.nombre_paciente, rem.exme_estserv_id, rem.c_cash_id, rem.canceledby, rem.motivocancel, rem.exme_motivocancel_id, rem.isprintedpre, rem.updatedbycancel, rem.numext, rem.numin, rem.sexo, rem.fechanac, rem.invoicephone, rem.exme_towncouncil_id, rem.tipooperacion, rem.observation, rem.dunninggrace, rem.m_rma_id, rem.c_dunninglevel_id, rem.invoicecollectiontype, rem.reversal_id, rem.verpoliza, rem.isgenerated, rem.globaldiscount, rem.sello, rem.cadena, rem.exme_ctapac_id, rem.conftype, rem.multiple_id, rem.ismultiple, rem.partner, rem.uuid, rem.estserv, rem.prepayment, rem.backoffice, rem.discounttaxamt, rem.taxamt, rem.exme_claimpayment_id, rem.coaseguro, rem.deducible, rem.coaseguromed, rem.copago, rem.coaseguroamt, rem.deducibleamt, rem.coaseguromedamt, rem.copagoamt, rem.ref_invoice_sales_id, rem.isinvoiced, rem.isorderfaclinecategory, rem.trxtype, rem.rebate, rem.sortby, rem.addenda, rem.sellosat, rem.certificadosat, rem.nocertificado, rem.certificado, rem.rate, rem.m_inout_id, rem.generatedfrom, rem.typeacct, rem.detailpayment, rem.c_cash_cancel_id, rem.datecanceled, rem.exme_areacaja_id, rem.accountno, rem.post, rem.statusuuid, rem.canceldescription, rem.versionno, rem.emprelationship, rem.perception, rem.comp_ditto, rem.perceptioniva, rem.afip, rem.date_comp, rem.typefac_ditto
  • Recheck Cond: ((rem.ad_client_id = $106) AND (rem.ad_org_id = $107) AND (rem.isactive = 'Y'::bpchar))
  • Rows Removed by Index Recheck: 427806
  • Heap Blocks: exact=26375 lossy=63731
  • Buffers: shared hit=10661 read=178174
  • Worker 0: actual time=151.307..1123.581 rows=172771 loops=1
  • Buffers: shared hit=5869 read=91199
281. 148.761 148.761 ↓ 280.8 336,651 1

Bitmap Index Scan on c_invoice_docstatus (cost=0.00..39.43 rows=1,199 width=0) (actual time=148.761..148.761 rows=336,651 loops=1)

  • Index Cond: ((rem.ad_client_id = $106) AND (rem.ad_org_id = $107) AND (rem.isactive = 'Y'::bpchar))
  • Buffers: shared read=1661
282. 0.002 0.002 ↓ 0.0 0 336,651

Index Scan using exme_ctapac_pkey on public.exme_ctapac cta (cost=0.42..7.67 rows=1 width=6) (actual time=0.002..0.002 rows=0 loops=336,651)

  • Output: cta.exme_ctapac_id, cta.ad_client_id, cta.ad_org_id, cta.isactive, cta.created, cta.createdby, cta.updated, cta.updatedby, cta.documentno, cta.docstatus, cta.docaction, cta.processing, cta.processed, cta.c_doctype_id, cta.c_doctypetarget_id, cta.description, cta.isapproved, cta.iscreditapproved, cta.isinvoiced, cta.isprinted, cta.dateordered, cta.dateprinted, cta.dateacct, cta.priorityrule, cta.grandtotal, cta.m_pricelist_id, cta.c_campaign_id, cta.c_project_id, cta.c_activity_id, cta.ad_user_id, cta.ad_orgtrx_id, cta.user1_id, cta.user2_id, cta.fechacancel, cta.exme_paciente_id, cta.exme_especialidad_id, cta.exme_motivocita_id, cta.estatus, cta.exme_medico_id, cta.ref_ctapac_id, cta.c_currency_id, cta.ad_printformat_id, cta.impcontrato, cta.impconsent, cta.impdatos, cta.impbrazalete, cta.exme_diagnostico_id, cta.exme_cama_id, cta.tipoarea, cta.fechacargodiario, cta.fechacierre, cta.exme_paqbase_version_id, cta.exme_ctapacext_id, cta.exme_estserv_id, cta.isuso, cta.isbloqueada, cta.isautorizada, cta.diagnostico_ingreso, cta.fechaalta, cta.actualizadoalta, cta.statusalta, cta.exme_camaing_id, cta.fechaprealta, cta.actualizadoprealta, cta.isfactespec, cta.ref_ctapacfam_id, cta.exme_descpreciofijo_id, cta.tiposangre, cta.exme_tipotrasplante_id, cta.exme_motivoegreso_id, cta.casosmedicos, cta.exme_estserving_id, cta.fechatraslado, cta.exme_procedencia_id, cta.isgenerated, cta.statuseleg, cta.instruccionalta, cta.nombrearchivo, cta.formatoarchivo, cta.archivo, cta.informealta, cta.exme_medico2_id, cta.exme_especialidad2_id, cta.exme_dischargestatus_id, cta.resstatus, cta.billingstatus, cta.exme_tipoprod_id, cta.drg, cta.exme_tipopaciente_id, cta.exme_arrivalmode_id, cta.exme_admittype_id, cta.exme_admitsource_id, cta.isnewborn, cta.exme_beneficiosh_id, cta.exme_estservprov_id, cta.billdate, cta.exme_area_id, cta.ref_unit_id, cta.encounterstatus, cta.exme_medicorefer_id, cta.exme_especialidadrefer_id, cta.exme_ctapacrefer_id, cta.isidentifier, cta.email, cta.requester, cta.fechaenv, cta.departuredate, cta.exme_pos_id, cta.exme_drg_id, cta.noinsurancecoverage, cta.nostatementage, cta.validonqueue, cta.exme_accompaniedby_id, cta.exme_transport_mode_id, cta.exme_discharged_via_id, cta.comments, cta.exme_institucion_id, cta.billingtype, cta.coded, cta.codingdate, cta.codedprof, cta.codingdateprof, cta.institutionalstatus, cta.institutionalstep, cta.isvalid, cta.nombre_pac, cta.mrn, cta.processingpaq, cta.processingpaq2, cta.isclosed, cta.exme_eventmerge_id, cta.fallrisk, cta.triage, cta.apollo_policy, cta.apollo_claim
  • Index Cond: (cta.exme_ctapac_id = rem.exme_ctapac_id)
  • Filter: ((COALESCE(cta.fechaalta, cta.fechacierre) IS NULL) AND (cta.fechacancel IS NULL) AND (cta.isactive = 'Y'::bpchar) AND (cta.ad_org_id = $108) AND ((cta.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=332597 read=11628
  • Worker 0: actual time=0.002..0.002 rows=0 loops=172771
  • Buffers: shared hit=176249 read=6396
283. 42.794 342.190 ↓ 0.0 0 19

Index Scan using c_invoice_ref_invoice_sales_id on public.c_invoice si_1 (cost=89,883.17..89,890.89 rows=1 width=12) (actual time=18.010..18.010 rows=0 loops=19)

  • Output: si_1.c_invoice_id, si_1.ad_client_id, si_1.ad_org_id, si_1.isactive, si_1.created, si_1.createdby, si_1.updated, si_1.updatedby, si_1.issotrx, si_1.documentno, si_1.docstatus, si_1.docaction, si_1.processing, si_1.processed, si_1.posted, si_1.c_doctype_id, si_1.c_doctypetarget_id, si_1.c_order_id, si_1.description, si_1.isapproved, si_1.istransferred, si_1.isprinted, si_1.salesrep_id, si_1.dateinvoiced, si_1.dateprinted, si_1.dateacct, si_1.c_bpartner_id, si_1.c_bpartner_location_id, si_1.poreference, si_1.isdiscountprinted, si_1.dateordered, si_1.c_currency_id, si_1.paymentrule, si_1.c_paymentterm_id, si_1.c_charge_id, si_1.chargeamt, si_1.totallines, si_1.grandtotal, si_1.m_pricelist_id, si_1.istaxincluded, si_1.c_campaign_id, si_1.c_project_id, si_1.c_activity_id, si_1.ispaid, si_1.c_payment_id, si_1.c_cashline_id, si_1.createfrom, si_1.generateto, si_1.sendemail, si_1.ad_user_id, si_1.copyfrom, si_1.isselfservice, si_1.ad_orgtrx_id, si_1.user1_id, si_1.user2_id, si_1.c_conversiontype_id, si_1.ispayschedulevalid, si_1.ref_invoice_id, si_1.isindispute, si_1.exme_ctapacext_id, si_1.descfromaseg, si_1.precfromaseg, si_1.documentnoext, si_1.afecta_caja, si_1.c_cashbook_id, si_1.discountporcent, si_1.discountamt, si_1.address1, si_1.address2, si_1.city, si_1.postal, si_1.c_country_id, si_1.c_region_id, si_1.address3, si_1.exme_paciente_id, si_1.exme_medico_id, si_1.nombre_medico, si_1.nombre_paciente, si_1.exme_estserv_id, si_1.c_cash_id, si_1.canceledby, si_1.motivocancel, si_1.exme_motivocancel_id, si_1.isprintedpre, si_1.updatedbycancel, si_1.numext, si_1.numin, si_1.sexo, si_1.fechanac, si_1.invoicephone, si_1.exme_towncouncil_id, si_1.tipooperacion, si_1.observation, si_1.dunninggrace, si_1.m_rma_id, si_1.c_dunninglevel_id, si_1.invoicecollectiontype, si_1.reversal_id, si_1.verpoliza, si_1.isgenerated, si_1.globaldiscount, si_1.sello, si_1.cadena, si_1.exme_ctapac_id, si_1.conftype, si_1.multiple_id, si_1.ismultiple, si_1.partner, si_1.uuid, si_1.estserv, si_1.prepayment, si_1.backoffice, si_1.discounttaxamt, si_1.taxamt, si_1.exme_claimpayment_id, si_1.coaseguro, si_1.deducible, si_1.coaseguromed, si_1.copago, si_1.coaseguroamt, si_1.deducibleamt, si_1.coaseguromedamt, si_1.copagoamt, si_1.ref_invoice_sales_id, si_1.isinvoiced, si_1.isorderfaclinecategory, si_1.trxtype, si_1.rebate, si_1.sortby, si_1.addenda, si_1.sellosat, si_1.certificadosat, si_1.nocertificado, si_1.certificado, si_1.rate, si_1.m_inout_id, si_1.generatedfrom, si_1.typeacct, si_1.detailpayment, si_1.c_cash_cancel_id, si_1.datecanceled, si_1.exme_areacaja_id, si_1.accountno, si_1.post, si_1.statusuuid, si_1.canceldescription, si_1.versionno, si_1.emprelationship, si_1.perception, si_1.comp_ditto, si_1.perceptioniva, si_1.afip, si_1.date_comp, si_1.typefac_ditto
  • Index Cond: (si_1.ref_invoice_sales_id = rem.c_invoice_id)
  • Filter: ((NOT (hashed SubPlan 51)) AND (si_1.isactive = 'Y'::bpchar) AND (si_1.issotrx = 'Y'::bpchar) AND (si_1.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=22124 read=39579
284.          

SubPlan (forIndex Scan)

285. 12.129 299.396 ↓ 120.4 59,694 1

Nested Loop (cost=0.56..89,881.50 rows=496 width=7) (actual time=0.195..299.396 rows=59,694 loops=1)

  • Output: ssi_4.ref_invoice_id
  • Buffers: shared hit=22071 read=39566
286. 3.347 3.347 ↓ 1.6 169 1

Seq Scan on public.c_doctype sd_1_1 (cost=0.00..347.14 rows=104 width=6) (actual time=0.046..3.347 rows=169 loops=1)

  • Output: sd_1_1.c_doctype_id, sd_1_1.ad_client_id, sd_1_1.ad_org_id, sd_1_1.isactive, sd_1_1.created, sd_1_1.createdby, sd_1_1.updated, sd_1_1.updatedby, sd_1_1.name, sd_1_1.printname, sd_1_1.description, sd_1_1.docbasetype, sd_1_1.issotrx, sd_1_1.docsubtypeso, sd_1_1.hasproforma, sd_1_1.c_doctypeproforma_id, sd_1_1.c_doctypeshipment_id, sd_1_1.c_doctypeinvoice_id, sd_1_1.isdocnocontrolled, sd_1_1.docnosequence_id, sd_1_1.gl_category_id, sd_1_1.hascharges, sd_1_1.documentnote, sd_1_1.isdefault, sd_1_1.documentcopies, sd_1_1.ad_printformat_id, sd_1_1.isdefaultcounterdoc, sd_1_1.isshipconfirm, sd_1_1.ispickqaconfirm, sd_1_1.isintransit, sd_1_1.issplitwhendifference, sd_1_1.c_doctypedifference_id, sd_1_1.iscreatecounter, sd_1_1.isindexed, sd_1_1.definitesequence_id, sd_1_1.isoverwriteseqoncomplete, sd_1_1.isoverwritedateoncomplete, sd_1_1.exme_typevouchercode_id, sd_1_1.exme_relationtypecode_id, sd_1_1.type
  • Filter: ((sd_1_1.docsubtypeso IS NULL) AND (sd_1_1.isactive = 'Y'::bpchar) AND (sd_1_1.docbasetype = 'ARC'::bpchar))
  • Rows Removed by Filter: 9174
  • Buffers: shared hit=3 read=204
287. 283.920 283.920 ↓ 1.5 353 169

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_4 (cost=0.56..858.60 rows=231 width=13) (actual time=0.030..1.680 rows=353 loops=169)

  • Output: ssi_4.isactive, ssi_4.c_doctype_id, ssi_4.docstatus, ssi_4.issotrx, ssi_4.c_invoice_id, ssi_4.ref_invoice_id, ssi_4.trxtype, ssi_4.issotrx
  • Index Cond: ((ssi_4.isactive = 'Y'::bpchar) AND (ssi_4.c_doctype_id = sd_1_1.c_doctype_id) AND (ssi_4.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_4.issotrx = 'Y'::bpchar) AND (ssi_4.trxtype = 'N'::bpchar))
  • Heap Fetches: 59694
  • Buffers: shared hit=22068 read=39362
288. 0.072 0.072 ↑ 1.0 1 8

Index Scan using c_doctype_c_doctype_id on public.c_doctype sd_2 (cost=0.29..0.31 rows=1 width=6) (actual time=0.009..0.009 rows=1 loops=8)

  • Output: sd_2.c_doctype_id, sd_2.ad_client_id, sd_2.ad_org_id, sd_2.isactive, sd_2.created, sd_2.createdby, sd_2.updated, sd_2.updatedby, sd_2.name, sd_2.printname, sd_2.description, sd_2.docbasetype, sd_2.issotrx, sd_2.docsubtypeso, sd_2.hasproforma, sd_2.c_doctypeproforma_id, sd_2.c_doctypeshipment_id, sd_2.c_doctypeinvoice_id, sd_2.isdocnocontrolled, sd_2.docnosequence_id, sd_2.gl_category_id, sd_2.hascharges, sd_2.documentnote, sd_2.isdefault, sd_2.documentcopies, sd_2.ad_printformat_id, sd_2.isdefaultcounterdoc, sd_2.isshipconfirm, sd_2.ispickqaconfirm, sd_2.isintransit, sd_2.issplitwhendifference, sd_2.c_doctypedifference_id, sd_2.iscreatecounter, sd_2.isindexed, sd_2.definitesequence_id, sd_2.isoverwriteseqoncomplete, sd_2.isoverwritedateoncomplete, sd_2.exme_typevouchercode_id, sd_2.exme_relationtypecode_id, sd_2.type
  • Index Cond: (sd_2.c_doctype_id = si_1.c_doctype_id)
  • Filter: ((sd_2.isactive = 'Y'::bpchar) AND (sd_2.docbasetype = 'ARI'::bpchar) AND (sd_2.docsubtypeso = 'SR'::bpchar))
  • Buffers: shared hit=24
289. 0.136 0.136 ↓ 0.0 0 8

Index Scan using c_cashline_c_invoice_id on public.c_cashline cline (cost=0.43..0.60 rows=1 width=12) (actual time=0.017..0.017 rows=0 loops=8)

  • Output: cline.c_cashline_id, cline.ad_client_id, cline.ad_org_id, cline.isactive, cline.created, cline.createdby, cline.updated, cline.updatedby, cline.c_cash_id, cline.line, cline.description, cline.cashtype, cline.c_bankaccount_id, cline.c_charge_id, cline.c_invoice_id, cline.c_currency_id, cline.amount, cline.discountamt, cline.writeoffamt, cline.isgenerated, cline.processed, cline.c_payment_id, cline.exme_ctapac_id, cline.exme_formapago_id, cline.creditcardtype, cline.creditcardnumber, cline.creditcardvv, cline.creditcardexpmm, cline.creditcardexpyy, cline.accountno, cline.checkno, cline.routingno, cline.micr, cline.isprepayment, cline.a_name, cline.recibono, cline.cambio, cline.exme_citamedica_id, cline.iscancelled, cline.ref_cash_id, cline.typeacct, cline.ref_cashline_id, cline.exme_methodpaymentcode_id, cline.rate
  • Index Cond: (cline.c_invoice_id = si_1.ref_invoice_sales_id)
  • Filter: ((cline.isactive = 'Y'::bpchar) AND (cline.cashtype = 'X'::bpchar))
  • Buffers: shared hit=11 read=13
290. 0.000 0.000 ↓ 0.0 0

Index Scan using c_cashline_pkey on public.c_cashline cashline (cost=0.43..8.45 rows=1 width=12) (never executed)

  • Output: cashline.c_cashline_id, cashline.ad_client_id, cashline.ad_org_id, cashline.isactive, cashline.created, cashline.createdby, cashline.updated, cashline.updatedby, cashline.c_cash_id, cashline.line, cashline.description, cashline.cashtype, cashline.c_bankaccount_id, cashline.c_charge_id, cashline.c_invoice_id, cashline.c_currency_id, cashline.amount, cashline.discountamt, cashline.writeoffamt, cashline.isgenerated, cashline.processed, cashline.c_payment_id, cashline.exme_ctapac_id, cashline.exme_formapago_id, cashline.creditcardtype, cashline.creditcardnumber, cashline.creditcardvv, cashline.creditcardexpmm, cashline.creditcardexpyy, cashline.accountno, cashline.checkno, cashline.routingno, cashline.micr, cashline.isprepayment, cashline.a_name, cashline.recibono, cashline.cambio, cashline.exme_citamedica_id, cashline.iscancelled, cashline.ref_cash_id, cashline.typeacct, cashline.ref_cashline_id, cashline.exme_methodpaymentcode_id, cashline.rate
  • Index Cond: (cashline.c_cashline_id = (min(cline.c_cashline_id) OVER (?)))
291. 0.000 0.000 ↓ 0.0 0

CTE Scan on pacientes pac_3 (cost=0.00..0.02 rows=1 width=16) (never executed)

  • Output: pac_3.exme_ctapac_id, pac_3.mrn, pac_3.encounter, pac_3.nombre_pac, pac_3.gender, pac_3.birth_date, pac_3.age_at_admission, pac_3.room, pac_3.bed, pac_3.tipopac, pac_3.physician, pac_3.specialty, pac_3.admission_diagnosis, pac_3.admission_diagnosis_trunk, pac_3.patient_type, pac_3.service_unit, pac_3.dateordered, pac_3.admit_date, pac_3.discharge_date, pac_3.los, pac_3.institucion, pac_3.fecha_prealta, pac_3.prealta, pac_3.destino
292.          

CTE pagosp

293. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=89,894.70..89,894.73 rows=1 width=48) (never executed)

  • Output: cta_1.exme_ctapac_id, sum(((allo.amount + allo.discountamt) + allo.writeoffamt))
  • Group Key: cta_1.exme_ctapac_id
294.          

Initplan (forGroupAggregate)

295. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_31 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_31.client_id
296. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_32 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_32.org_id
297. 0.000 0.000 ↓ 0.0 0

Sort (cost=89,894.66..89,894.67 rows=1 width=28) (never executed)

  • Output: cta_1.exme_ctapac_id, allo.amount, allo.discountamt, allo.writeoffamt
  • Sort Key: cta_1.exme_ctapac_id
298. 0.000 0.000 ↓ 0.0 0

Nested Loop Anti Join (cost=89,884.74..89,894.65 rows=1 width=28) (never executed)

  • Output: cta_1.exme_ctapac_id, allo.amount, allo.discountamt, allo.writeoffamt
299. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,884.31..89,894.09 rows=1 width=35) (never executed)

  • Output: cta_1.exme_ctapac_id, allo.amount, allo.discountamt, allo.writeoffamt, allo.c_payment_id
  • Inner Unique: true
300. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.89..89,893.62 rows=1 width=35) (never executed)

  • Output: cta_1.exme_ctapac_id, allo.amount, allo.discountamt, allo.writeoffamt, allo.c_payment_id
301. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.46..89,892.58 rows=1 width=22) (never executed)

  • Output: cta_1.exme_ctapac_id, si_2.c_invoice_id
  • Inner Unique: true
302. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.17..89,891.95 rows=2 width=28) (never executed)

  • Output: cta_1.exme_ctapac_id, si_2.c_doctype_id, si_2.c_invoice_id
303. 0.000 0.000 ↓ 0.0 0

CTE Scan on cxc cta_1 (cost=0.00..0.02 rows=1 width=16) (never executed)

  • Output: cta_1.exme_ctapac_id, cta_1.amount
304. 0.000 0.000 ↓ 0.0 0

Index Scan using ender_c_invoice_exme_ctapac on public.c_invoice si_2 (cost=89,883.17..89,891.91 rows=2 width=19) (never executed)

  • Output: si_2.c_invoice_id, si_2.ad_client_id, si_2.ad_org_id, si_2.isactive, si_2.created, si_2.createdby, si_2.updated, si_2.updatedby, si_2.issotrx, si_2.documentno, si_2.docstatus, si_2.docaction, si_2.processing, si_2.processed, si_2.posted, si_2.c_doctype_id, si_2.c_doctypetarget_id, si_2.c_order_id, si_2.description, si_2.isapproved, si_2.istransferred, si_2.isprinted, si_2.salesrep_id, si_2.dateinvoiced, si_2.dateprinted, si_2.dateacct, si_2.c_bpartner_id, si_2.c_bpartner_location_id, si_2.poreference, si_2.isdiscountprinted, si_2.dateordered, si_2.c_currency_id, si_2.paymentrule, si_2.c_paymentterm_id, si_2.c_charge_id, si_2.chargeamt, si_2.totallines, si_2.grandtotal, si_2.m_pricelist_id, si_2.istaxincluded, si_2.c_campaign_id, si_2.c_project_id, si_2.c_activity_id, si_2.ispaid, si_2.c_payment_id, si_2.c_cashline_id, si_2.createfrom, si_2.generateto, si_2.sendemail, si_2.ad_user_id, si_2.copyfrom, si_2.isselfservice, si_2.ad_orgtrx_id, si_2.user1_id, si_2.user2_id, si_2.c_conversiontype_id, si_2.ispayschedulevalid, si_2.ref_invoice_id, si_2.isindispute, si_2.exme_ctapacext_id, si_2.descfromaseg, si_2.precfromaseg, si_2.documentnoext, si_2.afecta_caja, si_2.c_cashbook_id, si_2.discountporcent, si_2.discountamt, si_2.address1, si_2.address2, si_2.city, si_2.postal, si_2.c_country_id, si_2.c_region_id, si_2.address3, si_2.exme_paciente_id, si_2.exme_medico_id, si_2.nombre_medico, si_2.nombre_paciente, si_2.exme_estserv_id, si_2.c_cash_id, si_2.canceledby, si_2.motivocancel, si_2.exme_motivocancel_id, si_2.isprintedpre, si_2.updatedbycancel, si_2.numext, si_2.numin, si_2.sexo, si_2.fechanac, si_2.invoicephone, si_2.exme_towncouncil_id, si_2.tipooperacion, si_2.observation, si_2.dunninggrace, si_2.m_rma_id, si_2.c_dunninglevel_id, si_2.invoicecollectiontype, si_2.reversal_id, si_2.verpoliza, si_2.isgenerated, si_2.globaldiscount, si_2.sello, si_2.cadena, si_2.exme_ctapac_id, si_2.conftype, si_2.multiple_id, si_2.ismultiple, si_2.partner, si_2.uuid, si_2.estserv, si_2.prepayment, si_2.backoffice, si_2.discounttaxamt, si_2.taxamt, si_2.exme_claimpayment_id, si_2.coaseguro, si_2.deducible, si_2.coaseguromed, si_2.copago, si_2.coaseguroamt, si_2.deducibleamt, si_2.coaseguromedamt, si_2.copagoamt, si_2.ref_invoice_sales_id, si_2.isinvoiced, si_2.isorderfaclinecategory, si_2.trxtype, si_2.rebate, si_2.sortby, si_2.addenda, si_2.sellosat, si_2.certificadosat, si_2.nocertificado, si_2.certificado, si_2.rate, si_2.m_inout_id, si_2.generatedfrom, si_2.typeacct, si_2.detailpayment, si_2.c_cash_cancel_id, si_2.datecanceled, si_2.exme_areacaja_id, si_2.accountno, si_2.post, si_2.statusuuid, si_2.canceldescription, si_2.versionno, si_2.emprelationship, si_2.perception, si_2.comp_ditto, si_2.perceptioniva, si_2.afip, si_2.date_comp, si_2.typefac_ditto
  • Index Cond: (si_2.exme_ctapac_id = cta_1.exme_ctapac_id)
  • Filter: ((NOT (hashed SubPlan 56)) AND (si_2.isactive = 'Y'::bpchar) AND (si_2.issotrx = 'Y'::bpchar) AND (si_2.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
305.          

SubPlan (forIndex Scan)

306. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..89,881.50 rows=496 width=7) (never executed)

  • Output: ssi_5.ref_invoice_id
307. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.c_doctype sd_1_2 (cost=0.00..347.14 rows=104 width=6) (never executed)

  • Output: sd_1_2.c_doctype_id, sd_1_2.ad_client_id, sd_1_2.ad_org_id, sd_1_2.isactive, sd_1_2.created, sd_1_2.createdby, sd_1_2.updated, sd_1_2.updatedby, sd_1_2.name, sd_1_2.printname, sd_1_2.description, sd_1_2.docbasetype, sd_1_2.issotrx, sd_1_2.docsubtypeso, sd_1_2.hasproforma, sd_1_2.c_doctypeproforma_id, sd_1_2.c_doctypeshipment_id, sd_1_2.c_doctypeinvoice_id, sd_1_2.isdocnocontrolled, sd_1_2.docnosequence_id, sd_1_2.gl_category_id, sd_1_2.hascharges, sd_1_2.documentnote, sd_1_2.isdefault, sd_1_2.documentcopies, sd_1_2.ad_printformat_id, sd_1_2.isdefaultcounterdoc, sd_1_2.isshipconfirm, sd_1_2.ispickqaconfirm, sd_1_2.isintransit, sd_1_2.issplitwhendifference, sd_1_2.c_doctypedifference_id, sd_1_2.iscreatecounter, sd_1_2.isindexed, sd_1_2.definitesequence_id, sd_1_2.isoverwriteseqoncomplete, sd_1_2.isoverwritedateoncomplete, sd_1_2.exme_typevouchercode_id, sd_1_2.exme_relationtypecode_id, sd_1_2.type
  • Filter: ((sd_1_2.docsubtypeso IS NULL) AND (sd_1_2.isactive = 'Y'::bpchar) AND (sd_1_2.docbasetype = 'ARC'::bpchar))
308. 0.000 0.000 ↓ 0.0 0

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_5 (cost=0.56..858.60 rows=231 width=13) (never executed)

  • Output: ssi_5.isactive, ssi_5.c_doctype_id, ssi_5.docstatus, ssi_5.issotrx, ssi_5.c_invoice_id, ssi_5.ref_invoice_id, ssi_5.trxtype, ssi_5.issotrx
  • Index Cond: ((ssi_5.isactive = 'Y'::bpchar) AND (ssi_5.c_doctype_id = sd_1_2.c_doctype_id) AND (ssi_5.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_5.issotrx = 'Y'::bpchar) AND (ssi_5.trxtype = 'N'::bpchar))
  • Heap Fetches: 0
309. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype sd_3 (cost=0.29..0.31 rows=1 width=6) (never executed)

  • Output: sd_3.c_doctype_id, sd_3.ad_client_id, sd_3.ad_org_id, sd_3.isactive, sd_3.created, sd_3.createdby, sd_3.updated, sd_3.updatedby, sd_3.name, sd_3.printname, sd_3.description, sd_3.docbasetype, sd_3.issotrx, sd_3.docsubtypeso, sd_3.hasproforma, sd_3.c_doctypeproforma_id, sd_3.c_doctypeshipment_id, sd_3.c_doctypeinvoice_id, sd_3.isdocnocontrolled, sd_3.docnosequence_id, sd_3.gl_category_id, sd_3.hascharges, sd_3.documentnote, sd_3.isdefault, sd_3.documentcopies, sd_3.ad_printformat_id, sd_3.isdefaultcounterdoc, sd_3.isshipconfirm, sd_3.ispickqaconfirm, sd_3.isintransit, sd_3.issplitwhendifference, sd_3.c_doctypedifference_id, sd_3.iscreatecounter, sd_3.isindexed, sd_3.definitesequence_id, sd_3.isoverwriteseqoncomplete, sd_3.isoverwritedateoncomplete, sd_3.exme_typevouchercode_id, sd_3.exme_relationtypecode_id, sd_3.type
  • Index Cond: (sd_3.c_doctype_id = si_2.c_doctype_id)
  • Filter: ((sd_3.isactive = 'Y'::bpchar) AND (sd_3.docbasetype = 'ARI'::bpchar) AND (sd_3.docsubtypeso = 'SR'::bpchar))
310. 0.000 0.000 ↓ 0.0 0

Index Scan using c_allocationline_invoice on public.c_allocationline allo (cost=0.43..0.94 rows=9 width=25) (never executed)

  • Output: allo.c_allocationline_id, allo.ad_client_id, allo.ad_org_id, allo.isactive, allo.created, allo.createdby, allo.updated, allo.updatedby, allo.allocationno, allo.datetrx, allo.ismanual, allo.c_invoice_id, allo.c_bpartner_id, allo.c_order_id, allo.c_payment_id, allo.c_cashline_id, allo.amount, allo.discountamt, allo.writeoffamt, allo.posted, allo.overunderamt, allo.c_allocationhdr_id, allo.c_charge_id, allo.amtacct, allo.creditmemo, allo.c_payselectionline_id, allo.rate, allo.gain, allo.amtbadge, allo.typeacct, allo.exme_paymentelectronic_id, allo.ref_invoice_id
  • Index Cond: (allo.c_invoice_id = si_2.c_invoice_id)
  • Filter: (allo.isactive = 'Y'::bpchar)
311. 0.000 0.000 ↓ 0.0 0

Index Only Scan using c_payment_pkey on public.c_payment p_5 (cost=0.42..0.48 rows=1 width=6) (never executed)

  • Output: p_5.c_payment_id
  • Index Cond: (p_5.c_payment_id = allo.c_payment_id)
  • Heap Fetches: 0
312. 0.000 0.000 ↓ 0.0 0

Index Scan using c_cashline_payment on public.c_cashline cl (cost=0.43..0.49 rows=1 width=7) (never executed)

  • Output: cl.c_cashline_id, cl.ad_client_id, cl.ad_org_id, cl.isactive, cl.created, cl.createdby, cl.updated, cl.updatedby, cl.c_cash_id, cl.line, cl.description, cl.cashtype, cl.c_bankaccount_id, cl.c_charge_id, cl.c_invoice_id, cl.c_currency_id, cl.amount, cl.discountamt, cl.writeoffamt, cl.isgenerated, cl.processed, cl.c_payment_id, cl.exme_ctapac_id, cl.exme_formapago_id, cl.creditcardtype, cl.creditcardnumber, cl.creditcardvv, cl.creditcardexpmm, cl.creditcardexpyy, cl.accountno, cl.checkno, cl.routingno, cl.micr, cl.isprepayment, cl.a_name, cl.recibono, cl.cambio, cl.exme_citamedica_id, cl.iscancelled, cl.ref_cash_id, cl.typeacct, cl.ref_cashline_id, cl.exme_methodpaymentcode_id, cl.rate
  • Index Cond: (cl.c_payment_id = allo.c_payment_id)
  • Filter: ((cl.isactive = 'Y'::bpchar) AND (cl.ad_client_id = $118) AND (cl.ad_org_id = $119))
313.          

CTE pagosc

314. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=89,893.21..89,893.23 rows=1 width=48) (never executed)

  • Output: cta_2.exme_ctapac_id, sum(cline_1.amount)
  • Group Key: cta_2.exme_ctapac_id
315. 0.000 0.000 ↓ 0.0 0

Sort (cost=89,893.21..89,893.21 rows=1 width=22) (never executed)

  • Output: cta_2.exme_ctapac_id, cline_1.amount
  • Sort Key: cta_2.exme_ctapac_id
316. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.89..89,893.20 rows=1 width=22) (never executed)

  • Output: cta_2.exme_ctapac_id, cline_1.amount
317. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.46..89,892.58 rows=1 width=22) (never executed)

  • Output: cta_2.exme_ctapac_id, si_3.c_invoice_id
  • Inner Unique: true
318. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=89,883.17..89,891.95 rows=2 width=28) (never executed)

  • Output: cta_2.exme_ctapac_id, si_3.c_doctype_id, si_3.c_invoice_id
319. 0.000 0.000 ↓ 0.0 0

CTE Scan on cxc cta_2 (cost=0.00..0.02 rows=1 width=16) (never executed)

  • Output: cta_2.exme_ctapac_id, cta_2.amount
320. 0.000 0.000 ↓ 0.0 0

Index Scan using ender_c_invoice_exme_ctapac on public.c_invoice si_3 (cost=89,883.17..89,891.91 rows=2 width=19) (never executed)

  • Output: si_3.c_invoice_id, si_3.ad_client_id, si_3.ad_org_id, si_3.isactive, si_3.created, si_3.createdby, si_3.updated, si_3.updatedby, si_3.issotrx, si_3.documentno, si_3.docstatus, si_3.docaction, si_3.processing, si_3.processed, si_3.posted, si_3.c_doctype_id, si_3.c_doctypetarget_id, si_3.c_order_id, si_3.description, si_3.isapproved, si_3.istransferred, si_3.isprinted, si_3.salesrep_id, si_3.dateinvoiced, si_3.dateprinted, si_3.dateacct, si_3.c_bpartner_id, si_3.c_bpartner_location_id, si_3.poreference, si_3.isdiscountprinted, si_3.dateordered, si_3.c_currency_id, si_3.paymentrule, si_3.c_paymentterm_id, si_3.c_charge_id, si_3.chargeamt, si_3.totallines, si_3.grandtotal, si_3.m_pricelist_id, si_3.istaxincluded, si_3.c_campaign_id, si_3.c_project_id, si_3.c_activity_id, si_3.ispaid, si_3.c_payment_id, si_3.c_cashline_id, si_3.createfrom, si_3.generateto, si_3.sendemail, si_3.ad_user_id, si_3.copyfrom, si_3.isselfservice, si_3.ad_orgtrx_id, si_3.user1_id, si_3.user2_id, si_3.c_conversiontype_id, si_3.ispayschedulevalid, si_3.ref_invoice_id, si_3.isindispute, si_3.exme_ctapacext_id, si_3.descfromaseg, si_3.precfromaseg, si_3.documentnoext, si_3.afecta_caja, si_3.c_cashbook_id, si_3.discountporcent, si_3.discountamt, si_3.address1, si_3.address2, si_3.city, si_3.postal, si_3.c_country_id, si_3.c_region_id, si_3.address3, si_3.exme_paciente_id, si_3.exme_medico_id, si_3.nombre_medico, si_3.nombre_paciente, si_3.exme_estserv_id, si_3.c_cash_id, si_3.canceledby, si_3.motivocancel, si_3.exme_motivocancel_id, si_3.isprintedpre, si_3.updatedbycancel, si_3.numext, si_3.numin, si_3.sexo, si_3.fechanac, si_3.invoicephone, si_3.exme_towncouncil_id, si_3.tipooperacion, si_3.observation, si_3.dunninggrace, si_3.m_rma_id, si_3.c_dunninglevel_id, si_3.invoicecollectiontype, si_3.reversal_id, si_3.verpoliza, si_3.isgenerated, si_3.globaldiscount, si_3.sello, si_3.cadena, si_3.exme_ctapac_id, si_3.conftype, si_3.multiple_id, si_3.ismultiple, si_3.partner, si_3.uuid, si_3.estserv, si_3.prepayment, si_3.backoffice, si_3.discounttaxamt, si_3.taxamt, si_3.exme_claimpayment_id, si_3.coaseguro, si_3.deducible, si_3.coaseguromed, si_3.copago, si_3.coaseguroamt, si_3.deducibleamt, si_3.coaseguromedamt, si_3.copagoamt, si_3.ref_invoice_sales_id, si_3.isinvoiced, si_3.isorderfaclinecategory, si_3.trxtype, si_3.rebate, si_3.sortby, si_3.addenda, si_3.sellosat, si_3.certificadosat, si_3.nocertificado, si_3.certificado, si_3.rate, si_3.m_inout_id, si_3.generatedfrom, si_3.typeacct, si_3.detailpayment, si_3.c_cash_cancel_id, si_3.datecanceled, si_3.exme_areacaja_id, si_3.accountno, si_3.post, si_3.statusuuid, si_3.canceldescription, si_3.versionno, si_3.emprelationship, si_3.perception, si_3.comp_ditto, si_3.perceptioniva, si_3.afip, si_3.date_comp, si_3.typefac_ditto
  • Index Cond: (si_3.exme_ctapac_id = cta_2.exme_ctapac_id)
  • Filter: ((NOT (hashed SubPlan 60)) AND (si_3.isactive = 'Y'::bpchar) AND (si_3.issotrx = 'Y'::bpchar) AND (si_3.docstatus = ANY ('{CO,CL,IP}'::bpchar[])))
321.          

SubPlan (forIndex Scan)

322. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.56..89,881.50 rows=496 width=7) (never executed)

  • Output: ssi_6.ref_invoice_id
323. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.c_doctype sd_1_3 (cost=0.00..347.14 rows=104 width=6) (never executed)

  • Output: sd_1_3.c_doctype_id, sd_1_3.ad_client_id, sd_1_3.ad_org_id, sd_1_3.isactive, sd_1_3.created, sd_1_3.createdby, sd_1_3.updated, sd_1_3.updatedby, sd_1_3.name, sd_1_3.printname, sd_1_3.description, sd_1_3.docbasetype, sd_1_3.issotrx, sd_1_3.docsubtypeso, sd_1_3.hasproforma, sd_1_3.c_doctypeproforma_id, sd_1_3.c_doctypeshipment_id, sd_1_3.c_doctypeinvoice_id, sd_1_3.isdocnocontrolled, sd_1_3.docnosequence_id, sd_1_3.gl_category_id, sd_1_3.hascharges, sd_1_3.documentnote, sd_1_3.isdefault, sd_1_3.documentcopies, sd_1_3.ad_printformat_id, sd_1_3.isdefaultcounterdoc, sd_1_3.isshipconfirm, sd_1_3.ispickqaconfirm, sd_1_3.isintransit, sd_1_3.issplitwhendifference, sd_1_3.c_doctypedifference_id, sd_1_3.iscreatecounter, sd_1_3.isindexed, sd_1_3.definitesequence_id, sd_1_3.isoverwriteseqoncomplete, sd_1_3.isoverwritedateoncomplete, sd_1_3.exme_typevouchercode_id, sd_1_3.exme_relationtypecode_id, sd_1_3.type
  • Filter: ((sd_1_3.docsubtypeso IS NULL) AND (sd_1_3.isactive = 'Y'::bpchar) AND (sd_1_3.docbasetype = 'ARC'::bpchar))
324. 0.000 0.000 ↓ 0.0 0

Index Only Scan using bi_c_invoice_customer_v_c_invoice on public.c_invoice ssi_6 (cost=0.56..858.60 rows=231 width=13) (never executed)

  • Output: ssi_6.isactive, ssi_6.c_doctype_id, ssi_6.docstatus, ssi_6.issotrx, ssi_6.c_invoice_id, ssi_6.ref_invoice_id, ssi_6.trxtype, ssi_6.issotrx
  • Index Cond: ((ssi_6.isactive = 'Y'::bpchar) AND (ssi_6.c_doctype_id = sd_1_3.c_doctype_id) AND (ssi_6.docstatus = ANY ('{CO,CL,IP}'::bpchar[])) AND (ssi_6.issotrx = 'Y'::bpchar) AND (ssi_6.trxtype = 'N'::bpchar))
  • Heap Fetches: 0
325. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype sd_4 (cost=0.29..0.31 rows=1 width=6) (never executed)

  • Output: sd_4.c_doctype_id, sd_4.ad_client_id, sd_4.ad_org_id, sd_4.isactive, sd_4.created, sd_4.createdby, sd_4.updated, sd_4.updatedby, sd_4.name, sd_4.printname, sd_4.description, sd_4.docbasetype, sd_4.issotrx, sd_4.docsubtypeso, sd_4.hasproforma, sd_4.c_doctypeproforma_id, sd_4.c_doctypeshipment_id, sd_4.c_doctypeinvoice_id, sd_4.isdocnocontrolled, sd_4.docnosequence_id, sd_4.gl_category_id, sd_4.hascharges, sd_4.documentnote, sd_4.isdefault, sd_4.documentcopies, sd_4.ad_printformat_id, sd_4.isdefaultcounterdoc, sd_4.isshipconfirm, sd_4.ispickqaconfirm, sd_4.isintransit, sd_4.issplitwhendifference, sd_4.c_doctypedifference_id, sd_4.iscreatecounter, sd_4.isindexed, sd_4.definitesequence_id, sd_4.isoverwriteseqoncomplete, sd_4.isoverwritedateoncomplete, sd_4.exme_typevouchercode_id, sd_4.exme_relationtypecode_id, sd_4.type
  • Index Cond: (sd_4.c_doctype_id = si_3.c_doctype_id)
  • Filter: ((sd_4.isactive = 'Y'::bpchar) AND (sd_4.docbasetype = 'ARI'::bpchar) AND (sd_4.docsubtypeso = 'SR'::bpchar))
326. 0.000 0.000 ↓ 0.0 0

Index Scan using c_cashline_c_invoice_id on public.c_cashline cline_1 (cost=0.43..0.60 rows=1 width=12) (never executed)

  • Output: cline_1.c_cashline_id, cline_1.ad_client_id, cline_1.ad_org_id, cline_1.isactive, cline_1.created, cline_1.createdby, cline_1.updated, cline_1.updatedby, cline_1.c_cash_id, cline_1.line, cline_1.description, cline_1.cashtype, cline_1.c_bankaccount_id, cline_1.c_charge_id, cline_1.c_invoice_id, cline_1.c_currency_id, cline_1.amount, cline_1.discountamt, cline_1.writeoffamt, cline_1.isgenerated, cline_1.processed, cline_1.c_payment_id, cline_1.exme_ctapac_id, cline_1.exme_formapago_id, cline_1.creditcardtype, cline_1.creditcardnumber, cline_1.creditcardvv, cline_1.creditcardexpmm, cline_1.creditcardexpyy, cline_1.accountno, cline_1.checkno, cline_1.routingno, cline_1.micr, cline_1.isprepayment, cline_1.a_name, cline_1.recibono, cline_1.cambio, cline_1.exme_citamedica_id, cline_1.iscancelled, cline_1.ref_cash_id, cline_1.typeacct, cline_1.ref_cashline_id, cline_1.exme_methodpaymentcode_id, cline_1.rate
  • Index Cond: (cline_1.c_invoice_id = si_3.c_invoice_id)
  • Filter: ((cline_1.cashtype <> 'X'::bpchar) AND (cline_1.isactive = 'Y'::bpchar))
327.          

CTE pagoscxcncp

328. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=20.60..20.63 rows=1 width=38) (never executed)

  • Output: cpac_3.exme_ctapac_id, sum(i_6.grandtotal)
  • Group Key: cpac_3.exme_ctapac_id
329.          

Initplan (forGroupAggregate)

330. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_33 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_33.org_id
331. 0.000 0.000 ↓ 0.0 0

CTE Scan on params params_34 (cost=0.00..0.02 rows=1 width=32) (never executed)

  • Output: params_34.org_id
332. 0.000 0.000 ↓ 0.0 0

Sort (cost=20.56..20.57 rows=1 width=12) (never executed)

  • Output: cpac_3.exme_ctapac_id, i_6.grandtotal
  • Sort Key: cpac_3.exme_ctapac_id
333. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.14..20.55 rows=1 width=12) (never executed)

  • Output: cpac_3.exme_ctapac_id, i_6.grandtotal
  • Inner Unique: true
334. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.85..16.83 rows=1 width=18) (never executed)

  • Output: i_6.grandtotal, i_6.c_doctype_id, cpac_3.exme_ctapac_id
  • Inner Unique: true
  • Join Filter: (cxc.exme_ctapac_id = cpac_3.exme_ctapac_id)
335. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..8.49 rows=1 width=35) (never executed)

  • Output: i_6.grandtotal, i_6.exme_ctapac_id, i_6.c_doctype_id, cxc.exme_ctapac_id
336. 0.000 0.000 ↓ 0.0 0

CTE Scan on cxc (cost=0.00..0.02 rows=1 width=16) (never executed)

  • Output: cxc.exme_ctapac_id, cxc.amount
337. 0.000 0.000 ↓ 0.0 0

Index Scan using ender_c_invoice_ctapac on public.c_invoice i_6 (cost=0.43..8.46 rows=1 width=19) (never executed)

  • Output: i_6.c_invoice_id, i_6.ad_client_id, i_6.ad_org_id, i_6.isactive, i_6.created, i_6.createdby, i_6.updated, i_6.updatedby, i_6.issotrx, i_6.documentno, i_6.docstatus, i_6.docaction, i_6.processing, i_6.processed, i_6.posted, i_6.c_doctype_id, i_6.c_doctypetarget_id, i_6.c_order_id, i_6.description, i_6.isapproved, i_6.istransferred, i_6.isprinted, i_6.salesrep_id, i_6.dateinvoiced, i_6.dateprinted, i_6.dateacct, i_6.c_bpartner_id, i_6.c_bpartner_location_id, i_6.poreference, i_6.isdiscountprinted, i_6.dateordered, i_6.c_currency_id, i_6.paymentrule, i_6.c_paymentterm_id, i_6.c_charge_id, i_6.chargeamt, i_6.totallines, i_6.grandtotal, i_6.m_pricelist_id, i_6.istaxincluded, i_6.c_campaign_id, i_6.c_project_id, i_6.c_activity_id, i_6.ispaid, i_6.c_payment_id, i_6.c_cashline_id, i_6.createfrom, i_6.generateto, i_6.sendemail, i_6.ad_user_id, i_6.copyfrom, i_6.isselfservice, i_6.ad_orgtrx_id, i_6.user1_id, i_6.user2_id, i_6.c_conversiontype_id, i_6.ispayschedulevalid, i_6.ref_invoice_id, i_6.isindispute, i_6.exme_ctapacext_id, i_6.descfromaseg, i_6.precfromaseg, i_6.documentnoext, i_6.afecta_caja, i_6.c_cashbook_id, i_6.discountporcent, i_6.discountamt, i_6.address1, i_6.address2, i_6.city, i_6.postal, i_6.c_country_id, i_6.c_region_id, i_6.address3, i_6.exme_paciente_id, i_6.exme_medico_id, i_6.nombre_medico, i_6.nombre_paciente, i_6.exme_estserv_id, i_6.c_cash_id, i_6.canceledby, i_6.motivocancel, i_6.exme_motivocancel_id, i_6.isprintedpre, i_6.updatedbycancel, i_6.numext, i_6.numin, i_6.sexo, i_6.fechanac, i_6.invoicephone, i_6.exme_towncouncil_id, i_6.tipooperacion, i_6.observation, i_6.dunninggrace, i_6.m_rma_id, i_6.c_dunninglevel_id, i_6.invoicecollectiontype, i_6.reversal_id, i_6.verpoliza, i_6.isgenerated, i_6.globaldiscount, i_6.sello, i_6.cadena, i_6.exme_ctapac_id, i_6.conftype, i_6.multiple_id, i_6.ismultiple, i_6.partner, i_6.uuid, i_6.estserv, i_6.prepayment, i_6.backoffice, i_6.discounttaxamt, i_6.taxamt, i_6.exme_claimpayment_id, i_6.coaseguro, i_6.deducible, i_6.coaseguromed, i_6.copago, i_6.coaseguroamt, i_6.deducibleamt, i_6.coaseguromedamt, i_6.copagoamt, i_6.ref_invoice_sales_id, i_6.isinvoiced, i_6.isorderfaclinecategory, i_6.trxtype, i_6.rebate, i_6.sortby, i_6.addenda, i_6.sellosat, i_6.certificadosat, i_6.nocertificado, i_6.certificado, i_6.rate, i_6.m_inout_id, i_6.generatedfrom, i_6.typeacct, i_6.detailpayment, i_6.c_cash_cancel_id, i_6.datecanceled, i_6.exme_areacaja_id, i_6.accountno, i_6.post, i_6.statusuuid, i_6.canceldescription, i_6.versionno, i_6.emprelationship, i_6.perception, i_6.comp_ditto, i_6.perceptioniva, i_6.afip, i_6.date_comp, i_6.typefac_ditto
  • Index Cond: ((i_6.exme_ctapac_id = cxc.exme_ctapac_id) AND (i_6.isactive = 'Y'::bpchar) AND (i_6.ad_org_id = $133))
  • Filter: ((i_6.issotrx = 'Y'::bpchar) AND (i_6.trxtype = 'P'::bpchar) AND (i_6.paymentrule = 'P'::bpchar) AND (i_6.docstatus = ANY ('{DR,CO,IP,CL}'::bpchar[])))
338. 0.000 0.000 ↓ 0.0 0

Index Scan using exme_ctapac_pkey on public.exme_ctapac cpac_3 (cost=0.42..8.33 rows=1 width=6) (never executed)

  • Output: cpac_3.exme_ctapac_id, cpac_3.ad_client_id, cpac_3.ad_org_id, cpac_3.isactive, cpac_3.created, cpac_3.createdby, cpac_3.updated, cpac_3.updatedby, cpac_3.documentno, cpac_3.docstatus, cpac_3.docaction, cpac_3.processing, cpac_3.processed, cpac_3.c_doctype_id, cpac_3.c_doctypetarget_id, cpac_3.description, cpac_3.isapproved, cpac_3.iscreditapproved, cpac_3.isinvoiced, cpac_3.isprinted, cpac_3.dateordered, cpac_3.dateprinted, cpac_3.dateacct, cpac_3.priorityrule, cpac_3.grandtotal, cpac_3.m_pricelist_id, cpac_3.c_campaign_id, cpac_3.c_project_id, cpac_3.c_activity_id, cpac_3.ad_user_id, cpac_3.ad_orgtrx_id, cpac_3.user1_id, cpac_3.user2_id, cpac_3.fechacancel, cpac_3.exme_paciente_id, cpac_3.exme_especialidad_id, cpac_3.exme_motivocita_id, cpac_3.estatus, cpac_3.exme_medico_id, cpac_3.ref_ctapac_id, cpac_3.c_currency_id, cpac_3.ad_printformat_id, cpac_3.impcontrato, cpac_3.impconsent, cpac_3.impdatos, cpac_3.impbrazalete, cpac_3.exme_diagnostico_id, cpac_3.exme_cama_id, cpac_3.tipoarea, cpac_3.fechacargodiario, cpac_3.fechacierre, cpac_3.exme_paqbase_version_id, cpac_3.exme_ctapacext_id, cpac_3.exme_estserv_id, cpac_3.isuso, cpac_3.isbloqueada, cpac_3.isautorizada, cpac_3.diagnostico_ingreso, cpac_3.fechaalta, cpac_3.actualizadoalta, cpac_3.statusalta, cpac_3.exme_camaing_id, cpac_3.fechaprealta, cpac_3.actualizadoprealta, cpac_3.isfactespec, cpac_3.ref_ctapacfam_id, cpac_3.exme_descpreciofijo_id, cpac_3.tiposangre, cpac_3.exme_tipotrasplante_id, cpac_3.exme_motivoegreso_id, cpac_3.casosmedicos, cpac_3.exme_estserving_id, cpac_3.fechatraslado, cpac_3.exme_procedencia_id, cpac_3.isgenerated, cpac_3.statuseleg, cpac_3.instruccionalta, cpac_3.nombrearchivo, cpac_3.formatoarchivo, cpac_3.archivo, cpac_3.informealta, cpac_3.exme_medico2_id, cpac_3.exme_especialidad2_id, cpac_3.exme_dischargestatus_id, cpac_3.resstatus, cpac_3.billingstatus, cpac_3.exme_tipoprod_id, cpac_3.drg, cpac_3.exme_tipopaciente_id, cpac_3.exme_arrivalmode_id, cpac_3.exme_admittype_id, cpac_3.exme_admitsource_id, cpac_3.isnewborn, cpac_3.exme_beneficiosh_id, cpac_3.exme_estservprov_id, cpac_3.billdate, cpac_3.exme_area_id, cpac_3.ref_unit_id, cpac_3.encounterstatus, cpac_3.exme_medicorefer_id, cpac_3.exme_especialidadrefer_id, cpac_3.exme_ctapacrefer_id, cpac_3.isidentifier, cpac_3.email, cpac_3.requester, cpac_3.fechaenv, cpac_3.departuredate, cpac_3.exme_pos_id, cpac_3.exme_drg_id, cpac_3.noinsurancecoverage, cpac_3.nostatementage, cpac_3.validonqueue, cpac_3.exme_accompaniedby_id, cpac_3.exme_transport_mode_id, cpac_3.exme_discharged_via_id, cpac_3.comments, cpac_3.exme_institucion_id, cpac_3.billingtype, cpac_3.coded, cpac_3.codingdate, cpac_3.codedprof, cpac_3.codingdateprof, cpac_3.institutionalstatus, cpac_3.institutionalstep, cpac_3.isvalid, cpac_3.nombre_pac, cpac_3.mrn, cpac_3.processingpaq, cpac_3.processingpaq2, cpac_3.isclosed, cpac_3.exme_eventmerge_id, cpac_3.fallrisk, cpac_3.triage, cpac_3.apollo_policy, cpac_3.apollo_claim
  • Index Cond: (cpac_3.exme_ctapac_id = i_6.exme_ctapac_id)
  • Filter: ((COALESCE(cpac_3.fechaalta, cpac_3.fechacierre) IS NULL) AND (cpac_3.fechacancel IS NULL) AND (cpac_3.ad_org_id = $132) AND (cpac_3.isactive = 'Y'::bpchar) AND ((cpac_3.tipoarea)::text = ANY ('{A,H,O,U}'::text[])))
339. 0.000 0.000 ↓ 0.0 0

Index Scan using c_doctype_c_doctype_id on public.c_doctype dt_9 (cost=0.29..3.65 rows=1 width=6) (never executed)

  • Output: dt_9.c_doctype_id, dt_9.ad_client_id, dt_9.ad_org_id, dt_9.isactive, dt_9.created, dt_9.createdby, dt_9.updated, dt_9.updatedby, dt_9.name, dt_9.printname, dt_9.description, dt_9.docbasetype, dt_9.issotrx, dt_9.docsubtypeso, dt_9.hasproforma, dt_9.c_doctypeproforma_id, dt_9.c_doctypeshipment_id, dt_9.c_doctypeinvoice_id, dt_9.isdocnocontrolled, dt_9.docnosequence_id, dt_9.gl_category_id, dt_9.hascharges, dt_9.documentnote, dt_9.isdefault, dt_9.documentcopies, dt_9.ad_printformat_id, dt_9.isdefaultcounterdoc, dt_9.isshipconfirm, dt_9.ispickqaconfirm, dt_9.isintransit, dt_9.issplitwhendifference, dt_9.c_doctypedifference_id, dt_9.iscreatecounter, dt_9.isindexed, dt_9.definitesequence_id, dt_9.isoverwriteseqoncomplete, dt_9.isoverwritedateoncomplete, dt_9.exme_typevouchercode_id, dt_9.exme_relationtypecode_id, dt_9.type
  • Index Cond: (dt_9.c_doctype_id = i_6.c_doctype_id)
  • Filter: ((dt_9.docsubtypeso IS NULL) AND (dt_9.isactive = 'Y'::bpchar) AND (dt_9.docbasetype = 'ARC'::bpchar))
340. 0.017 1,626.553 ↓ 0.0 0 1

Sort (cost=0.18..0.18 rows=1 width=112) (actual time=1,626.553..1,626.553 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, (((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))), ((cxc_1.amount - ((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))))
  • Sort Key: cxc_1.exme_ctapac_id, cxc_1.amount, (((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))), ((cxc_1.amount - ((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric))))
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=365417 read=229394
341. 0.044 1,626.536 ↓ 0.0 0 1

WindowAgg (cost=0.13..0.17 rows=1 width=112) (actual time=1,626.536..1,626.536 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, ((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric)), (cxc_1.amount - ((COALESCE(sum(p_6.amount) OVER (?), '0'::numeric) + COALESCE(sum(c_3.amount) OVER (?), '0'::numeric)) + COALESCE(sum(ncp.amount) OVER (?), '0'::numeric)))
  • Buffers: shared hit=365417 read=229394
342. 0.014 1,626.492 ↓ 0.0 0 1

Sort (cost=0.13..0.13 rows=1 width=144) (actual time=1,626.492..1,626.492 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, p_6.amount, c_3.amount, ncp.amount
  • Sort Key: cxc_1.exme_ctapac_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=365417 read=229394
343. 0.015 1,626.478 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.00..0.12 rows=1 width=144) (actual time=1,626.478..1,626.478 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, p_6.amount, c_3.amount, ncp.amount
  • Join Filter: (ncp.exme_ctapac_id = cxc_1.exme_ctapac_id)
  • Buffers: shared hit=365417 read=229394
344. 0.018 1,626.463 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.00..0.09 rows=1 width=112) (actual time=1,626.463..1,626.463 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, p_6.amount, c_3.amount
  • Join Filter: (c_3.exme_ctapac_id = cxc_1.exme_ctapac_id)
  • Buffers: shared hit=365417 read=229394
345. 0.007 1,626.445 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.00..0.05 rows=1 width=80) (actual time=1,626.445..1,626.445 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount, p_6.amount
  • Join Filter: (p_6.exme_ctapac_id = cxc_1.exme_ctapac_id)
  • Buffers: shared hit=365417 read=229394
346. 1,626.438 1,626.438 ↓ 0.0 0 1

CTE Scan on cxc cxc_1 (cost=0.00..0.02 rows=1 width=48) (actual time=1,626.438..1,626.438 rows=0 loops=1)

  • Output: cxc_1.exme_ctapac_id, cxc_1.amount
  • Buffers: shared hit=365417 read=229394
347. 0.000 0.000 ↓ 0.0 0

CTE Scan on pagosp p_6 (cost=0.00..0.02 rows=1 width=48) (never executed)

  • Output: p_6.exme_ctapac_id, p_6.amount
348. 0.000 0.000 ↓ 0.0 0

CTE Scan on pagosc c_3 (cost=0.00..0.02 rows=1 width=48) (never executed)

  • Output: c_3.exme_ctapac_id, c_3.amount
349. 0.000 0.000 ↓ 0.0 0

CTE Scan on pagoscxcncp ncp (cost=0.00..0.02 rows=1 width=48) (never executed)

  • Output: ncp.exme_ctapac_id, ncp.amount
350.          

CTE todo

351. 0.151 7,160.745 ↓ 48.0 48 1

Unique (cost=0.89..0.99 rows=1 width=4,032) (actual time=7,160.604..7,160.745 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, (COALESCE(c_4.cargos, '0'::numeric)), (COALESCE(c1_1.cargos, '0'::numeric)), (COALESCE(c1f.subtotal, '0'::numeric)), (COALESCE(c1f.iva, '0'::numeric)), ((COALESCE(c1f.facturado, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(c1r.facturado, '0'::numeric)), (COALESCE(a_2.anticipos, '0'::numeric)), (COALESCE(aa.anticipos, '0'::numeric)), ((COALESCE(pa_1.pago, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(cxc_2.cxc, '0'::numeric)), (COALESCE(cxc_2.pagos, '0'::numeric)), (COALESCE(cxc_2.saldo, '0'::numeric)), ((((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)) + COALESCE(a_2.anticipos, '0'::numeric))), (((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)))
  • Buffers: shared hit=1125686 read=615847 written=386
352. 0.198 7,160.594 ↓ 48.0 48 1

Sort (cost=0.89..0.90 rows=1 width=4,032) (actual time=7,160.590..7,160.594 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, (COALESCE(c_4.cargos, '0'::numeric)), (COALESCE(c1_1.cargos, '0'::numeric)), (COALESCE(c1f.subtotal, '0'::numeric)), (COALESCE(c1f.iva, '0'::numeric)), ((COALESCE(c1f.facturado, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(c1r.facturado, '0'::numeric)), (COALESCE(a_2.anticipos, '0'::numeric)), (COALESCE(aa.anticipos, '0'::numeric)), ((COALESCE(pa_1.pago, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(cxc_2.cxc, '0'::numeric)), (COALESCE(cxc_2.pagos, '0'::numeric)), (COALESCE(cxc_2.saldo, '0'::numeric)), ((((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)) + COALESCE(a_2.anticipos, '0'::numeric))), (((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)))
  • Sort Key: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, (COALESCE(c_4.cargos, '0'::numeric)), (COALESCE(c1_1.cargos, '0'::numeric)), (COALESCE(c1f.subtotal, '0'::numeric)), (COALESCE(c1f.iva, '0'::numeric)), ((COALESCE(c1f.facturado, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(c1r.facturado, '0'::numeric)), (COALESCE(a_2.anticipos, '0'::numeric)), (COALESCE(aa.anticipos, '0'::numeric)), ((COALESCE(pa_1.pago, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric))), (COALESCE(cxc_2.cxc, '0'::numeric)), (COALESCE(cxc_2.pagos, '0'::numeric)), (COALESCE(cxc_2.saldo, '0'::numeric)), ((((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)) + COALESCE(a_2.anticipos, '0'::numeric))), (((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)))
  • Sort Method: quicksort Memory: 49kB
  • Buffers: shared hit=1125686 read=615847 written=386
353. 0.171 7,160.396 ↓ 48.0 48 1

Nested Loop Left Join (cost=0.43..0.88 rows=1 width=4,032) (actual time=7,159.529..7,160.396 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, COALESCE(c_4.cargos, '0'::numeric), COALESCE(c1_1.cargos, '0'::numeric), COALESCE(c1f.subtotal, '0'::numeric), COALESCE(c1f.iva, '0'::numeric), (COALESCE(c1f.facturado, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric)), COALESCE(c1r.facturado, '0'::numeric), COALESCE(a_2.anticipos, '0'::numeric), COALESCE(aa.anticipos, '0'::numeric), (COALESCE(pa_1.pago, '0'::numeric) + COALESCE(rfg.facturado, '0'::numeric)), COALESCE(cxc_2.cxc, '0'::numeric), COALESCE(cxc_2.pagos, '0'::numeric), COALESCE(cxc_2.saldo, '0'::numeric), (((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric)) + COALESCE(a_2.anticipos, '0'::numeric)), ((COALESCE(c_4.cargos, '0'::numeric) + COALESCE(c1_1.cargos, '0'::numeric)) + COALESCE(c1r.facturado, '0'::numeric))
  • Join Filter: (rfg.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=1125677 read=615847 written=386
354. 0.053 5,562.113 ↓ 48.0 48 1

Nested Loop Left Join (cost=0.43..0.83 rows=1 width=3,968) (actual time=5,561.327..5,562.113 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c_4.cargos, c1_1.cargos, c1f.subtotal, c1f.iva, c1f.facturado, c1r.facturado, a_2.anticipos, aa.anticipos, pa_1.pago, cxc_2.cxc, cxc_2.pagos, cxc_2.saldo
  • Join Filter: (cxc_2.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=1116434 read=528034 written=386
355. 0.351 3,935.484 ↓ 48.0 48 1

Nested Loop Left Join (cost=0.43..0.80 rows=1 width=3,872) (actual time=3,934.727..3,935.484 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c_4.cargos, c1_1.cargos, c1f.subtotal, c1f.iva, c1f.facturado, c1r.facturado, a_2.anticipos, aa.anticipos, pa_1.pago
  • Join Filter: (a_2.exme_ctapac_id = p_7.exme_ctapac_id)
  • Rows Removed by Join Filter: 1410
  • Buffers: shared hit=751017 read=298640 written=386
356. 0.073 3,760.221 ↓ 48.0 48 1

Nested Loop Left Join (cost=0.43..0.77 rows=1 width=3,840) (actual time=3,759.952..3,760.221 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c_4.cargos, c1_1.cargos, c1f.subtotal, c1f.iva, c1f.facturado, c1r.facturado, aa.anticipos, pa_1.pago
  • Join Filter: (c1r.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=688314 read=274769 written=386
357. 0.150 3,681.044 ↓ 48.0 48 1

Nested Loop Left Join (cost=0.43..0.74 rows=1 width=3,808) (actual time=3,680.814..3,681.044 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c_4.cargos, c1_1.cargos, c1f.subtotal, c1f.iva, c1f.facturado, aa.anticipos, pa_1.pago
  • Join Filter: (c1f.exme_ctapac_id = p_7.exme_ctapac_id)
  • Rows Removed by Join Filter: 376
  • Buffers: shared hit=675740 read=267667 written=386
358. 0.101 1,467.614 ↓ 48.0 48 1

Hash Right Join (cost=0.43..0.70 rows=1 width=3,712) (actual time=1,467.543..1,467.614 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c_4.cargos, c1_1.cargos, aa.anticipos, pa_1.pago
  • Hash Cond: (c_4.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=295257 read=96332 written=372
359. 66.202 66.202 ↑ 1.1 10 1

CTE Scan on cargos0 c_4 (cost=0.00..0.22 rows=11 width=48) (actual time=66.182..66.202 rows=10 loops=1)

  • Output: c_4.exme_ctapac_id, c_4.cargos
  • Buffers: shared hit=26567
360. 0.096 1,401.311 ↓ 48.0 48 1

Hash (cost=0.42..0.42 rows=1 width=3,680) (actual time=1,401.311..1,401.311 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c1_1.cargos, aa.anticipos, pa_1.pago
  • Buckets: 1024 Batches: 1 Memory Usage: 22kB
  • Buffers: shared hit=268690 read=96332 written=372
361. 0.085 1,401.215 ↓ 48.0 48 1

Hash Right Join (cost=0.29..0.42 rows=1 width=3,680) (actual time=1,401.176..1,401.215 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c1_1.cargos, aa.anticipos, pa_1.pago
  • Hash Cond: (aa.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=268690 read=96332 written=372
362. 195.693 195.693 ↓ 1.6 8 1

CTE Scan on anticipos_a aa (cost=0.00..0.10 rows=5 width=48) (actual time=195.687..195.693 rows=8 loops=1)

  • Output: aa.exme_ctapac_id, aa.anticipos
  • Buffers: shared hit=85925 read=21575 written=372
363. 0.085 1,205.437 ↓ 48.0 48 1

Hash (cost=0.28..0.28 rows=1 width=3,648) (actual time=1,205.437..1,205.437 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c1_1.cargos, pa_1.pago
  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
  • Buffers: shared hit=182765 read=74757
364. 0.067 1,205.352 ↓ 48.0 48 1

Hash Right Join (cost=0.15..0.28 rows=1 width=3,648) (actual time=1,205.323..1,205.352 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, c1_1.cargos, pa_1.pago
  • Hash Cond: (c1_1.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=182765 read=74757
365. 64.923 64.923 ↓ 0.0 0 1

CTE Scan on cargos1 c1_1 (cost=0.00..0.10 rows=5 width=48) (actual time=64.923..64.923 rows=0 loops=1)

  • Output: c1_1.exme_ctapac_id, c1_1.cargos
  • Buffers: shared hit=25705 read=862
366. 0.103 1,140.362 ↓ 48.0 48 1

Hash (cost=0.14..0.14 rows=1 width=3,616) (actual time=1,140.362..1,140.362 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, pa_1.pago
  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
  • Buffers: shared hit=157060 read=73895
367. 0.121 1,140.259 ↓ 48.0 48 1

Hash Right Join (cost=0.03..0.14 rows=1 width=3,616) (actual time=1,140.198..1,140.259 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino, pa_1.pago
  • Hash Cond: (pa_1.exme_ctapac_id = p_7.exme_ctapac_id)
  • Buffers: shared hit=157060 read=73895
368. 962.992 962.992 ↓ 0.0 0 1

CTE Scan on pagos pa_1 (cost=0.00..0.08 rows=4 width=48) (actual time=962.992..962.992 rows=0 loops=1)

  • Output: pa_1.exme_ctapac_id, pa_1.pago
  • Buffers: shared hit=156297 read=54239
369. 0.064 177.146 ↓ 48.0 48 1

Hash (cost=0.02..0.02 rows=1 width=3,584) (actual time=177.146..177.146 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino
  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
  • Buffers: shared hit=763 read=19656
370. 177.082 177.082 ↓ 48.0 48 1

CTE Scan on pacientes p_7 (cost=0.00..0.02 rows=1 width=3,584) (actual time=177.004..177.082 rows=48 loops=1)

  • Output: p_7.exme_ctapac_id, p_7.mrn, p_7.encounter, p_7.nombre_pac, p_7.gender, p_7.birth_date, p_7.age_at_admission, p_7.room, p_7.bed, p_7.tipopac, p_7.physician, p_7.specialty, p_7.admission_diagnosis, p_7.admission_diagnosis_trunk, p_7.patient_type, p_7.service_unit, p_7.dateordered, p_7.admit_date, p_7.discharge_date, p_7.los, p_7.institucion, p_7.fecha_prealta, p_7.prealta, p_7.destino
  • Buffers: shared hit=763 read=19656
371. 2,213.280 2,213.280 ↓ 8.0 8 48

CTE Scan on cargos1f c1f (cost=0.00..0.02 rows=1 width=112) (actual time=46.109..46.110 rows=8 loops=48)

  • Output: c1f.exme_ctapac_id, c1f.subtotal, c1f.iva, c1f.facturado
  • Buffers: shared hit=380483 read=171335 written=14
372. 79.104 79.104 ↓ 0.0 0 48

CTE Scan on cargos1r c1r (cost=0.00..0.02 rows=1 width=48) (actual time=1.648..1.648 rows=0 loops=48)

  • Output: c1r.exme_ctapac_id, c1r.facturado
  • Buffers: shared hit=12574 read=7102
373. 174.912 174.912 ↓ 30.0 30 48

CTE Scan on anticipos_sa a_2 (cost=0.00..0.02 rows=1 width=48) (actual time=3.640..3.644 rows=30 loops=48)

  • Output: a_2.exme_ctapac_id, a_2.anticipos
  • Buffers: shared hit=62703 read=23871
374. 1,626.576 1,626.576 ↓ 0.0 0 48

CTE Scan on cxc2 cxc_2 (cost=0.00..0.02 rows=1 width=112) (actual time=33.887..33.887 rows=0 loops=48)

  • Output: cxc_2.exme_ctapac_id, cxc_2.cxc, cxc_2.pagos, cxc_2.saldo
  • Buffers: shared hit=365417 read=229394
375. 1,598.112 1,598.112 ↓ 0.0 0 48

CTE Scan on cargos1r_fg rfg (cost=0.00..0.02 rows=1 width=48) (actual time=33.294..33.294 rows=0 loops=48)

  • Output: rfg.exme_ctapac_id, rfg.facturado
  • Buffers: shared hit=9243 read=87813
376.          

CTE final

377. 0.060 7,160.878 ↓ 10.0 10 1

Sort (cost=0.04..0.04 rows=1 width=4,032) (actual time=7,160.877..7,160.878 rows=10 loops=1)

  • Output: todo.exme_ctapac_id, todo.mrn, todo.encounter, todo.nombre_pac, todo.gender, todo.birth_date, todo.age_at_admission, todo.room, todo.bed, todo.tipopac, todo.physician, todo.specialty, todo.admission_diagnosis, todo.admission_diagnosis_trunk, todo.patient_type, todo.service_unit, todo.dateordered, todo.admit_date, todo.discharge_date, todo.los, todo.institucion, todo.fecha_prealta, todo.prealta, todo.destino, todo.cargos, todo.cargos1, todo.subtotal, todo.iva, todo.cargosfacturados, todo.cargosremisiones, todo.anticipos, todo.anticipos_aplicados, todo.pagos, todo.cxc, todo.pagoscxc, todo.saldocxc, todo.saldo_con_anticipos, todo.saldo
  • Sort Key: todo.encounter
  • Sort Method: quicksort Memory: 30kB
  • Buffers: shared hit=1125689 read=615847 written=386
378. 7,160.818 7,160.818 ↓ 10.0 10 1

CTE Scan on todo (cost=0.00..0.03 rows=1 width=4,032) (actual time=7,160.777..7,160.818 rows=10 loops=1)

  • Output: todo.exme_ctapac_id, todo.mrn, todo.encounter, todo.nombre_pac, todo.gender, todo.birth_date, todo.age_at_admission, todo.room, todo.bed, todo.tipopac, todo.physician, todo.specialty, todo.admission_diagnosis, todo.admission_diagnosis_trunk, todo.patient_type, todo.service_unit, todo.dateordered, todo.admit_date, todo.discharge_date, todo.los, todo.institucion, todo.fecha_prealta, todo.prealta, todo.destino, todo.cargos, todo.cargos1, todo.subtotal, todo.iva, todo.cargosfacturados, todo.cargosremisiones, todo.anticipos, todo.anticipos_aplicados, todo.pagos, todo.cxc, todo.pagoscxc, todo.saldocxc, todo.saldo_con_anticipos, todo.saldo
  • Filter: ((todo.saldo > 0.01) OR (todo.saldo < '-0.01'::numeric))
  • Rows Removed by Filter: 38
  • Buffers: shared hit=1125686 read=615847 written=386
379. 7,160.904 7,160.904 ↓ 10.0 10 1

CTE Scan on final (cost=0.00..0.02 rows=1 width=4,032) (actual time=7,160.895..7,160.904 rows=10 loops=1)

  • Output: final.exme_ctapac_id, final.mrn, final.encounter, final.nombre_pac, final.gender, final.birth_date, final.age_at_admission, final.room, final.bed, final.tipopac, final.physician, final.specialty, final.admission_diagnosis, final.admission_diagnosis_trunk, final.patient_type, final.service_unit, final.dateordered, final.admit_date, final.discharge_date, final.los, final.institucion, final.fecha_prealta, final.prealta, final.destino, final.cargos, final.cargos1, final.subtotal, final.iva, final.cargosfacturados, final.cargosremisiones, final.anticipos, final.anticipos_aplicados, final.pagos, final.cxc, final.pagoscxc, final.saldocxc, final.saldo_con_anticipos, final.saldo
  • Buffers: shared hit=1125689 read=615847 written=386
Planning time : 152.776 ms
Execution time : 7,184.649 ms