explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 4JiL : Optimization for: Optimization for: Optimization for: plan #3o9f; plan #J9Xm; plan #1yS

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 6,976.439 7,434.654 ↑ 83.3 12 1

Function Scan on pg_catalog.generate_series mes (cost=31,167.09..57,570,351.01 rows=1,000 width=184) (actual time=1,046.690..7,434.654 rows=12 loops=1)

  • Output: (SubPlan 2), (SubPlan 5), (SubPlan 8), (SubPlan 11), (SubPlan 14), COALESCE((SubPlan 17), '0'::double precision), (SubPlan 20), COALESCE((SubPlan 23), '0'::double precision), ((SubPlan 25) - COALESCE((SubPlan 28), '0'::double precision)), (SubPlan 29), ((((SubPlan 30) * '100'::double precision) / (SubPlan 33)) - '100'::double precision), (SubPlan 34), $60, ((COALESCE((SubPlan 36), '0'::double precision) - COALESCE((SubPlan 39), '0'::double precision)) - COALESCE((SubPlan 40), '0'::double precision)), COALESCE((SubPlan 41), '0'::double precision), CASE WHEN (mes.mes = 1) THEN 'Jan'::text WHEN (mes.mes = 2) THEN 'Fev'::text WHEN (mes.mes = 3) THEN 'Mar'::text WHEN (mes.mes = 4) THEN 'Abr'::text WHEN (mes.mes = 5) THEN 'Mai'::text WHEN (mes.mes = 6) THEN 'Jun'::text WHEN (mes.mes = 7) THEN 'Jul'::text WHEN (mes.mes = 8) THEN 'Ago'::text WHEN (mes.mes = 9) THEN 'Set'::text WHEN (mes.mes = 10) THEN 'Out'::text WHEN (mes.mes = 11) THEN 'Nov'::text WHEN (mes.mes = 12) THEN 'Dez'::text ELSE ''::text END, 2019, mes.mes, ((SubPlan 43) - ($81 + COALESCE((SubPlan 47), '0'::double precision))), $87, $97
  • Function Call: generate_series(1, 12)
  • Buffers: shared hit=597800, temp read=3382 written=3382
2.          

Initplan (for Function Scan)

3. 0.017 176.535 ↑ 1.0 1 1

Aggregate (cost=10,064.10..10,064.11 rows=1 width=8) (actual time=176.535..176.535 rows=1 loops=1)

  • Output: sum(trp_9."trpValorRecebido")
  • Buffers: shared hit=2874, temp read=335 written=335
4. 0.126 176.518 ↓ 23.0 23 1

Nested Loop (cost=7,029.16..10,064.10 rows=1 width=8) (actual time=146.834..176.518 rows=23 loops=1)

  • Output: trp_9."trpValorRecebido
  • Buffers: shared hit=2874, temp read=335 written=335
5. 0.082 176.286 ↓ 106.0 106 1

Nested Loop (cost=7,029.01..10,063.92 rows=1 width=12) (actual time=139.564..176.286 rows=106 loops=1)

  • Output: trp_9."trpValorRecebido", tpc_1."tpctasID
  • Buffers: shared hit=2662, temp read=335 written=335
6. 0.212 175.886 ↓ 106.0 106 1

Nested Loop (cost=7,028.73..10,062.35 rows=1 width=12) (actual time=139.553..175.886 rows=106 loops=1)

  • Output: tos_11."tostpcID", trp_9."trpValorRecebido
  • Buffers: shared hit=2344, temp read=335 written=335
7. 0.101 175.330 ↓ 172.0 172 1

Nested Loop (cost=7,028.45..10,061.85 rows=1 width=12) (actual time=139.525..175.330 rows=172 loops=1)

  • Output: trec_9."trectosID", trp_9."trpValorRecebido
  • Buffers: shared hit=1826, temp read=335 written=335
8. 18.286 174.713 ↓ 172.0 172 1

Subquery Scan on trp_9 (cost=7,028.17..10,053.54 rows=1 width=12) (actual time=139.495..174.713 rows=172 loops=1)

  • Output: trp_9."trptrecID", trp_9."trpDataCompensacao", trp_9."trpDataRecebimento", trp_9."trpBaixada", trp_9."trpSubstituida", trp_9."trpIsExcluido", trp_9."trpValorRecebido", trp_9.r, "TabReceitaParcela_1"."trpDataVencimento
  • Filter: ((trp_9."trpBaixada" IS FALSE) AND (trp_9."trpSubstituida" IS FALSE) AND (NOT trp_9."trpIsExcluido") AND (trp_9.r = 1) AND (date_part('month'::text, COALESCE((trp_9."trpDataCompensacao")::timestamp with time zone, trp_9."trpDataRecebimento")) = '6'::double precision) AND (date_part('year'::text, COALESCE((trp_9."trpDataCompensacao")::timestamp with time zone, trp_9."trpDataRecebimento")) = '2019'::double precision))
  • Rows Removed by Filter: 63483
  • Buffers: shared hit=1309, temp read=335 written=335
9. 44.388 156.427 ↑ 1.0 63,655 1

WindowAgg (cost=7,028.17..8,302.01 rows=63,692 width=39) (actual time=93.318..156.427 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_1"."trptrecID", "TabReceitaParcela_1"."trpDataCompensacao", "TabReceitaParcela_1"."trpDataRecebimento", "TabReceitaParcela_1"."trpBaixada", "TabReceitaParcela_1"."trpSubstituida", "TabReceitaParcela_1"."trpIsExcluido", "TabReceitaParcela_1"."trpValorRecebido", row_number() OVER (?), "TabReceitaParcela_1"."trpDataVencimento
  • Buffers: shared hit=1309, temp read=335 written=335
10. 81.387 112.039 ↑ 1.0 63,655 1

Sort (cost=7,028.17..7,187.40 rows=63,692 width=31) (actual time=93.310..112.039 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_1"."trptrecID", "TabReceitaParcela_1"."trpDataVencimento", "TabReceitaParcela_1"."trpDataCompensacao", "TabReceitaParcela_1"."trpDataRecebimento", "TabReceitaParcela_1"."trpBaixada", "TabReceitaParcela_1"."trpSubstituida", "TabReceitaParcela_1"."trpIsExcluido", "TabReceitaParcela_1"."trpValorRecebido
  • Sort Key: "TabReceitaParcela_1"."trptrecID", "TabReceitaParcela_1"."trpDataVencimento" DESC
  • Sort Method: external merge Disk: 2672kB
  • Buffers: shared hit=1309, temp read=335 written=335
11. 30.652 30.652 ↑ 1.0 63,655 1

Seq Scan on public."TabReceitaParcela" "TabReceitaParcela_1" (cost=0.00..1,945.92 rows=63,692 width=31) (actual time=0.015..30.652 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_1"."trptrecID", "TabReceitaParcela_1"."trpDataVencimento", "TabReceitaParcela_1"."trpDataCompensacao", "TabReceitaParcela_1"."trpDataRecebimento", "TabReceitaParcela_1"."trpBaixada", "TabReceitaParcela_1"."trpSubstituida", "TabReceitaParcela_1"."trpIsExcluido", "TabReceitaParcela_1"."trpValorRecebido
  • Buffers: shared hit=1309
12. 0.516 0.516 ↑ 1.0 1 172

Index Scan using "TabReceita_trecID" on public."TabReceita" trec_9 (cost=0.28..8.30 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=172)

  • Output: trec_9."trecID", trec_9."trectclID", trec_9."trecCondicaoPagamento", trec_9."trecDataCompetencia", trec_9."trecObservacao", trec_9."trectemID", trec_9."trectosID", trec_9."trectrosID", trec_9."trectfuID", trec_9."trectfoID", trec_9."trecRecurrentBilling
  • Index Cond: (trec_9."trecID" = trp_9."trptrecID")
  • Buffers: shared hit=517
13. 0.344 0.344 ↑ 1.0 1 172

Index Scan using "TabOrdemServico_tosID" on public."TabOrdemServico" tos_11 (cost=0.28..0.50 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=172)

  • Output: tos_11."tosID", tos_11."tostpcID
  • Index Cond: (tos_11."tosID" = trec_9."trectosID")
  • Filter: (tos_11."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=518
14. 0.318 0.318 ↑ 1.0 1 106

Index Scan using "TabPropostaComercial_tpcID" on public."TabPropostaComercial" tpc_1 (cost=0.28..1.55 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=106)

  • Output: tpc_1."tpcID", tpc_1."tpcPrazoValidade", tpc_1."tpcObservacao", tpc_1."tpcProximoContato", tpc_1."tpcCondPagamento", tpc_1."tpctasID", tpc_1."tpcMeioContato", tpc_1."tpcDescricaoAssessoria", tpc_1."tpcValorAssessoria", tpc_1."tpcValorMarkupAssessoria", tpc_1."tpcTaxaCancelamentoAssessoria", tpc_1."tpcCategoriaAssessoria", tpc_1."tpcPorcComissaoAssessoria", tpc_1."tpcPorcDespAdmAssessoria", tpc_1."tpcPorcLucroAssessoria", tpc_1."tpcValorCustoAssessoria", tpc_1."tpcDescontoPadraoAssessoria", tpc_1."tpcCNPJCPFContato", tpc_1."tpcNomeContato", tpc_1."tpcTelefonesContato", tpc_1."tpcEmailsContato", tpc_1."tpctfuID", tpc_1."tpcAprovado", tpc_1."tpcOrigemContato", tpc_1."tpcNumCondPagamento", tpc_1."tpctemID", tpc_1."tpcDescritivoAssessoria", tpc_1."tpcDuracaoAssessoria", tpc_1."tpcPeriodoCarenciaAssessoria", tpc_1."tpcValorProposta", tpc_1."tpctccID", tpc_1."tpcIDPai
  • Index Cond: (tpc_1."tpcID" = tos_11."tostpcID")
  • Buffers: shared hit=318
15. 0.106 0.106 ↓ 0.0 0 106

Index Scan using "TabAssessoria_tasID" on public."TabAssessoria" tas_1 (cost=0.14..0.17 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=106)

  • Output: tas_1."tasID", tas_1."tasDescricao", tas_1."tasValor", tas_1."tasValorMarkup", tas_1."tasAtivo", tas_1."tasTaxaCancelamento", tas_1."tasCategoriaAssessoria", tas_1."tasPorcDespAdm", tas_1."tasPorcComissao", tas_1."tasPorcLucro", tas_1."tasValorCusto", tas_1."tasDescontoPadrao", tas_1."tasDescritivo", tas_1."tastemID", tas_1."tasDuracao", tas_1."tasPeriodoCarencia", tas_1."tastmeaID", tas_1."tasIsRenovado", tas_1."tasObservacaoGeral", tas_1."tasTermoAprovacao", tas_1."tasIsObservacaoObrigatoria", tas_1."tasTipoGatilhoFaturamento", tas_1."tasDiaGatilhoFaturamento", tas_1."tasTipoVenda", tas_1."tasStatus", tas_1."tasMetadata
  • Index Cond: (tas_1."tasID" = tpc_1."tpctasID")
  • Filter: (tas_1."tasIsRenovado" IS FALSE)
  • Rows Removed by Filter: 1
  • Buffers: shared hit=212
16. 0.017 174.125 ↑ 1.0 1 1

Aggregate (cost=10,064.10..10,064.11 rows=1 width=8) (actual time=174.125..174.125 rows=1 loops=1)

  • Output: sum(trp_13."trpValorRecebido")
  • Buffers: shared hit=2874, temp read=335 written=335
17. 0.113 174.108 ↓ 23.0 23 1

Nested Loop (cost=7,029.16..10,064.10 rows=1 width=8) (actual time=144.674..174.108 rows=23 loops=1)

  • Output: trp_13."trpValorRecebido
  • Buffers: shared hit=2874, temp read=335 written=335
18. 0.086 173.889 ↓ 106.0 106 1

Nested Loop (cost=7,029.01..10,063.92 rows=1 width=12) (actual time=137.369..173.889 rows=106 loops=1)

  • Output: trp_13."trpValorRecebido", tpc_2."tpctasID
  • Buffers: shared hit=2662, temp read=335 written=335
19. 0.211 173.485 ↓ 106.0 106 1

Nested Loop (cost=7,028.73..10,062.35 rows=1 width=12) (actual time=137.358..173.485 rows=106 loops=1)

  • Output: tos_14."tostpcID", trp_13."trpValorRecebido
  • Buffers: shared hit=2344, temp read=335 written=335
20. 0.282 172.930 ↓ 172.0 172 1

Nested Loop (cost=7,028.45..10,061.85 rows=1 width=12) (actual time=137.334..172.930 rows=172 loops=1)

  • Output: trec_13."trectosID", trp_13."trpValorRecebido
  • Buffers: shared hit=1826, temp read=335 written=335
21. 17.879 172.304 ↓ 172.0 172 1

Subquery Scan on trp_13 (cost=7,028.17..10,053.54 rows=1 width=12) (actual time=137.301..172.304 rows=172 loops=1)

  • Output: trp_13."trptrecID", trp_13."trpDataCompensacao", trp_13."trpDataRecebimento", trp_13."trpBaixada", trp_13."trpSubstituida", trp_13."trpIsExcluido", trp_13."trpValorRecebido", trp_13.r, "TabReceitaParcela_2"."trpDataVencimento
  • Filter: ((trp_13."trpBaixada" IS FALSE) AND (trp_13."trpSubstituida" IS FALSE) AND (NOT trp_13."trpIsExcluido") AND (trp_13.r = 1) AND (date_part('month'::text, COALESCE((trp_13."trpDataCompensacao")::timestamp with time zone, trp_13."trpDataRecebimento")) = '6'::double precision) AND (date_part('year'::text, COALESCE((trp_13."trpDataCompensacao")::timestamp with time zone, trp_13."trpDataRecebimento")) = '2019'::double precision))
  • Rows Removed by Filter: 63483
  • Buffers: shared hit=1309, temp read=335 written=335
22. 43.924 154.425 ↑ 1.0 63,655 1

WindowAgg (cost=7,028.17..8,302.01 rows=63,692 width=39) (actual time=91.599..154.425 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_2"."trptrecID", "TabReceitaParcela_2"."trpDataCompensacao", "TabReceitaParcela_2"."trpDataRecebimento", "TabReceitaParcela_2"."trpBaixada", "TabReceitaParcela_2"."trpSubstituida", "TabReceitaParcela_2"."trpIsExcluido", "TabReceitaParcela_2"."trpValorRecebido", row_number() OVER (?), "TabReceitaParcela_2"."trpDataVencimento
  • Buffers: shared hit=1309, temp read=335 written=335
23. 80.624 110.501 ↑ 1.0 63,655 1

Sort (cost=7,028.17..7,187.40 rows=63,692 width=31) (actual time=91.589..110.501 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_2"."trptrecID", "TabReceitaParcela_2"."trpDataVencimento", "TabReceitaParcela_2"."trpDataCompensacao", "TabReceitaParcela_2"."trpDataRecebimento", "TabReceitaParcela_2"."trpBaixada", "TabReceitaParcela_2"."trpSubstituida", "TabReceitaParcela_2"."trpIsExcluido", "TabReceitaParcela_2"."trpValorRecebido
  • Sort Key: "TabReceitaParcela_2"."trptrecID", "TabReceitaParcela_2"."trpDataVencimento" DESC
  • Sort Method: external merge Disk: 2672kB
  • Buffers: shared hit=1309, temp read=335 written=335
24. 29.877 29.877 ↑ 1.0 63,655 1

Seq Scan on public."TabReceitaParcela" "TabReceitaParcela_2" (cost=0.00..1,945.92 rows=63,692 width=31) (actual time=0.011..29.877 rows=63,655 loops=1)

  • Output: "TabReceitaParcela_2"."trptrecID", "TabReceitaParcela_2"."trpDataVencimento", "TabReceitaParcela_2"."trpDataCompensacao", "TabReceitaParcela_2"."trpDataRecebimento", "TabReceitaParcela_2"."trpBaixada", "TabReceitaParcela_2"."trpSubstituida", "TabReceitaParcela_2"."trpIsExcluido", "TabReceitaParcela_2"."trpValorRecebido
  • Buffers: shared hit=1309
25. 0.344 0.344 ↑ 1.0 1 172

Index Scan using "TabReceita_trecID" on public."TabReceita" trec_13 (cost=0.28..8.30 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=172)

  • Output: trec_13."trecID", trec_13."trectclID", trec_13."trecCondicaoPagamento", trec_13."trecDataCompetencia", trec_13."trecObservacao", trec_13."trectemID", trec_13."trectosID", trec_13."trectrosID", trec_13."trectfuID", trec_13."trectfoID", trec_13."trecRecurrentBilling
  • Index Cond: (trec_13."trecID" = trp_13."trptrecID")
  • Buffers: shared hit=517
26. 0.344 0.344 ↑ 1.0 1 172

Index Scan using "TabOrdemServico_tosID" on public."TabOrdemServico" tos_14 (cost=0.28..0.50 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=172)

  • Output: tos_14."tosID", tos_14."tostpcID
  • Index Cond: (tos_14."tosID" = trec_13."trectosID")
  • Filter: (tos_14."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=518
27. 0.318 0.318 ↑ 1.0 1 106

Index Scan using "TabPropostaComercial_tpcID" on public."TabPropostaComercial" tpc_2 (cost=0.28..1.55 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=106)

  • Output: tpc_2."tpcID", tpc_2."tpcPrazoValidade", tpc_2."tpcObservacao", tpc_2."tpcProximoContato", tpc_2."tpcCondPagamento", tpc_2."tpctasID", tpc_2."tpcMeioContato", tpc_2."tpcDescricaoAssessoria", tpc_2."tpcValorAssessoria", tpc_2."tpcValorMarkupAssessoria", tpc_2."tpcTaxaCancelamentoAssessoria", tpc_2."tpcCategoriaAssessoria", tpc_2."tpcPorcComissaoAssessoria", tpc_2."tpcPorcDespAdmAssessoria", tpc_2."tpcPorcLucroAssessoria", tpc_2."tpcValorCustoAssessoria", tpc_2."tpcDescontoPadraoAssessoria", tpc_2."tpcCNPJCPFContato", tpc_2."tpcNomeContato", tpc_2."tpcTelefonesContato", tpc_2."tpcEmailsContato", tpc_2."tpctfuID", tpc_2."tpcAprovado", tpc_2."tpcOrigemContato", tpc_2."tpcNumCondPagamento", tpc_2."tpctemID", tpc_2."tpcDescritivoAssessoria", tpc_2."tpcDuracaoAssessoria", tpc_2."tpcPeriodoCarenciaAssessoria", tpc_2."tpcValorProposta", tpc_2."tpctccID", tpc_2."tpcIDPai
  • Index Cond: (tpc_2."tpcID" = tos_14."tostpcID")
  • Buffers: shared hit=318
28. 0.106 0.106 ↓ 0.0 0 106

Index Scan using "TabAssessoria_tasID" on public."TabAssessoria" tas_2 (cost=0.14..0.17 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=106)

  • Output: tas_2."tasID", tas_2."tasDescricao", tas_2."tasValor", tas_2."tasValorMarkup", tas_2."tasAtivo", tas_2."tasTaxaCancelamento", tas_2."tasCategoriaAssessoria", tas_2."tasPorcDespAdm", tas_2."tasPorcComissao", tas_2."tasPorcLucro", tas_2."tasValorCusto", tas_2."tasDescontoPadrao", tas_2."tasDescritivo", tas_2."tastemID", tas_2."tasDuracao", tas_2."tasPeriodoCarencia", tas_2."tastmeaID", tas_2."tasIsRenovado", tas_2."tasObservacaoGeral", tas_2."tasTermoAprovacao", tas_2."tasIsObservacaoObrigatoria", tas_2."tasTipoGatilhoFaturamento", tas_2."tasDiaGatilhoFaturamento", tas_2."tasTipoVenda", tas_2."tasStatus", tas_2."tasMetadata
  • Index Cond: (tas_2."tasID" = tpc_2."tpctasID")
  • Filter: (tas_2."tasIsRenovado" IS FALSE)
  • Rows Removed by Filter: 1
  • Buffers: shared hit=212
29. 3.157 47.339 ↑ 1.0 1 1

Aggregate (cost=2,678.48..2,678.49 rows=1 width=8) (actual time=47.338..47.339 rows=1 loops=1)

  • Output: sum(trp_15."trpValorRecebido")
  • Buffers: shared hit=1405
30. 8.237 44.182 ↓ 85.8 12,695 1

Hash Join (cost=252.28..2,678.11 rows=148 width=8) (actual time=3.932..44.182 rows=12,695 loops=1)

  • Output: trp_15."trpValorRecebido
  • Hash Cond: (trp_15."trptrecID" = trec_15."trecID")
  • Buffers: shared hit=1405
31. 32.104 32.104 ↓ 78.8 15,593 1

Seq Scan on public."TabReceitaParcela" trp_15 (cost=0.00..2,423.61 rows=198 width=12) (actual time=0.041..32.104 rows=15,593 loops=1)

  • Output: trp_15."trpID", trp_15."trpValorParcela", trp_15."trpPago", trp_15."trpDesconto", trp_15."trpDataVencimento", trp_15."trptrecID", trp_15."trpMulta", trp_15."trpDataRecebimento", trp_15."trpSubstituida", trp_15."trpParcelaSubstitutaID", trp_15."trpBaixada", trp_15."trpTipoBaixa", trp_15."trpTipoDocumento", trp_15."trpNumDocumento", trp_15."trpNumeroParcela", trp_15."trptcbID", trp_15."trpDataBaixa", trp_15."trpJuros", trp_15."trpSubstituta", trp_15."trpObservacao", trp_15."trpEmitidoRemessa", trp_15."trpDataRemessa", trp_15."trptcoconID", trp_15."trpPagoParcial", trp_15."trptrpOriundaID", trp_15."trpValorRecebido", trp_15."trpEmCobranca", trp_15."trpNossoNumero", trp_15."trptremID", trp_15."trpObservacaoBaixa", trp_15."trpObservacaoSubstituicao", trp_15."trpIsExcluido", trp_15."trpEmiteNFSe", trp_15."trpDataCompensacao", trp_15."trpEmitidoNFSe", trp_15."trpImpostoRetido", trp_15."trpDataDisponibilidade", trp_15."trptcfosID", trp_15."trpIsEntrada
  • Filter: ((trp_15."trpBaixada" IS FALSE) AND (trp_15."trpPago" IS TRUE) AND (trp_15."trpSubstituida" IS FALSE) AND (NOT trp_15."trpIsExcluido") AND (date_part('year'::text, COALESCE((trp_15."trpDataCompensacao")::timestamp with time zone, trp_15."trpDataRecebimento")) = '2018'::double precision))
  • Rows Removed by Filter: 48062
  • Buffers: shared hit=1309
32. 1.694 3.841 ↓ 1.0 5,354 1

Hash (cost=185.38..185.38 rows=5,352 width=4) (actual time=3.841..3.841 rows=5,354 loops=1)

  • Output: trec_15."trecID
  • Buckets: 8192 Batches: 1 Memory Usage: 253kB
  • Buffers: shared hit=96
33. 2.147 2.147 ↓ 1.0 5,354 1

Seq Scan on public."TabReceita" trec_15 (cost=0.00..185.38 rows=5,352 width=4) (actual time=0.007..2.147 rows=5,354 loops=1)

  • Output: trec_15."trecID
  • Filter: (trec_15."trectemID" = ANY ('{1,2}'::integer[]))
  • Rows Removed by Filter: 1799
  • Buffers: shared hit=96
34. 32.050 60.216 ↑ 1.0 1 1

Aggregate (cost=8,360.37..8,360.39 rows=1 width=8) (actual time=60.214..60.216 rows=1 loops=1)

  • Output: (((sum(trp_17."trpValorParcela") - sum(trp_17."trpDesconto")) - COALESCE($89, '0'::double precision)) - COALESCE($94, '0'::double precision))
  • Buffers: shared hit=6766
35.          

Initplan (for Aggregate)

36. 0.020 26.351 ↑ 1.0 1 1

Aggregate (cost=4,732.11..4,732.12 rows=1 width=8) (actual time=26.350..26.351 rows=1 loops=1)

  • Output: (sum(trp_1_5."trpValorParcela") - sum(trp_1_5."trpDesconto"))
  • Buffers: shared hit=1428
37. 0.003 26.331 ↓ 0.0 0 1

Nested Loop (cost=936.32..4,732.10 rows=1 width=16) (actual time=26.330..26.331 rows=0 loops=1)

  • Output: trp_1_5."trpValorParcela", trp_1_5."trpDesconto
  • Buffers: shared hit=1428
38. 22.464 26.328 ↓ 0.0 0 1

Bitmap Heap Scan on public."TabReceitaParcela" trp_1_5 (cost=936.04..4,723.79 rows=1 width=20) (actual time=26.327..26.328 rows=0 loops=1)

  • Output: trp_1_5."trpID", trp_1_5."trpValorParcela", trp_1_5."trpPago", trp_1_5."trpDesconto", trp_1_5."trpDataVencimento", trp_1_5."trptrecID", trp_1_5."trpMulta", trp_1_5."trpDataRecebimento", trp_1_5."trpSubstituida", trp_1_5."trpParcelaSubstitutaID", trp_1_5."trpBaixada", trp_1_5."trpTipoBaixa", trp_1_5."trpTipoDocumento", trp_1_5."trpNumDocumento", trp_1_5."trpNumeroParcela", trp_1_5."trptcbID", trp_1_5."trpDataBaixa", trp_1_5."trpJuros", trp_1_5."trpSubstituta", trp_1_5."trpObservacao", trp_1_5."trpEmitidoRemessa", trp_1_5."trpDataRemessa", trp_1_5."trptcoconID", trp_1_5."trpPagoParcial", trp_1_5."trptrpOriundaID", trp_1_5."trpValorRecebido", trp_1_5."trpEmCobranca", trp_1_5."trpNossoNumero", trp_1_5."trptremID", trp_1_5."trpObservacaoBaixa", trp_1_5."trpObservacaoSubstituicao", trp_1_5."trpIsExcluido", trp_1_5."trpEmiteNFSe", trp_1_5."trpDataCompensacao", trp_1_5."trpEmitidoNFSe", trp_1_5."trpImpostoRetido", trp_1_5."trpDataDisponibilidade", trp_1_5."trptcfosID", trp_1_5."trpIsEntrada
  • Filter: ((trp_1_5."trpPago" IS TRUE) AND (trp_1_5."trpSubstituida" IS FALSE) AND (trp_1_5."trpBaixada" IS FALSE) AND (NOT trp_1_5."trpIsExcluido") AND (date_part('year'::text, (trp_1_5."trpDataVencimento")::timestamp without time zone) = '2020'::double precision) AND (date_part('month'::text, (trp_1_5."trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (((date_part('year'::text, COALESCE((trp_1_5."trpDataCompensacao")::timestamp with time zone, trp_1_5."trpDataRecebimento")) = date_part('year'::text, (trp_1_5."trpDataVencimento")::timestamp without time zone)) AND (date_part('month'::text, COALESCE((trp_1_5."trpDataCompensacao")::timestamp with time zone, trp_1_5."trpDataRecebimento")) < date_part('month'::text, (trp_1_5."trpDataVencimento")::timestamp without time zone))) OR (date_part('year'::text, COALESCE((trp_1_5."trpDataCompensacao")::timestamp with time zone, trp_1_5."trpDataRecebimento")) < date_part('year'::text, (trp_1_5."trpDataVencimento")::timestamp without time zone))))
  • Rows Removed by Filter: 44717
  • Heap Blocks: exact=1304
  • Buffers: shared hit=1428
39. 3.864 3.864 ↓ 1.1 44,717 1

Bitmap Index Scan on idx_trp_trppago_trpsubstituida_trpbaixada_trpdatavencimento (cost=0.00..936.04 rows=39,660 width=0) (actual time=3.864..3.864 rows=44,717 loops=1)

  • Index Cond: ((trp_1_5."trpPago" = true) AND (trp_1_5."trpSubstituida" = false) AND (trp_1_5."trpBaixada" = false))
  • Buffers: shared hit=124
40. 0.000 0.000 ↓ 0.0 0

Index Scan using "TabReceita_trecID" on public."TabReceita" trec_1_5 (cost=0.28..8.30 rows=1 width=4) (never executed)

  • Output: trec_1_5."trecID", trec_1_5."trectclID", trec_1_5."trecCondicaoPagamento", trec_1_5."trecDataCompetencia", trec_1_5."trecObservacao", trec_1_5."trectemID", trec_1_5."trectosID", trec_1_5."trectrosID", trec_1_5."trectfuID", trec_1_5."trectfoID", trec_1_5."trecRecurrentBilling
  • Index Cond: (trec_1_5."trecID" = trp_1_5."trptrecID")
  • Filter: (trec_1_5."trectemID" = ANY ('{5,1}'::integer[]))
41. 0.010 1.815 ↑ 1.0 1 1

Aggregate (cost=718.28..718.30 rows=1 width=8) (actual time=1.815..1.815 rows=1 loops=1)

  • Output: (sum(trp_16."trpValorParcela") - sum(trp_16."trpDesconto"))
  • Buffers: shared hit=201
42. 0.001 1.805 ↓ 0.0 0 1

Nested Loop (cost=522.71..718.28 rows=1 width=16) (actual time=1.805..1.805 rows=0 loops=1)

  • Output: trp_16."trpValorParcela", trp_16."trpDesconto
  • Buffers: shared hit=201
43. 0.001 1.804 ↓ 0.0 0 1

Nested Loop (cost=522.42..716.80 rows=1 width=4) (actual time=1.804..1.804 rows=0 loops=1)

  • Output: trec_16."trecID
  • Join Filter: (tlsos_11."tlsostosID" = tos_16."tosID")
  • Buffers: shared hit=201
44. 0.023 1.803 ↓ 0.0 0 1

Hash Join (cost=522.14..716.46 rows=1 width=12) (actual time=1.803..1.803 rows=0 loops=1)

  • Output: tlsos_11."tlsostosID", trec_16."trectosID", trec_16."trecID
  • Hash Cond: (trec_16."trectosID" = tlsos_11."tlsostosID")
  • Buffers: shared hit=201
45. 0.010 0.010 ↑ 7,150.0 1 1

Seq Scan on public."TabReceita" trec_16 (cost=0.00..167.50 rows=7,150 width=8) (actual time=0.010..0.010 rows=1 loops=1)

  • Output: trec_16."trecID", trec_16."trectclID", trec_16."trecCondicaoPagamento", trec_16."trecDataCompetencia", trec_16."trecObservacao", trec_16."trectemID", trec_16."trectosID", trec_16."trectrosID", trec_16."trectfuID", trec_16."trectfoID", trec_16."trecRecurrentBilling
  • Buffers: shared hit=1
46. 0.000 1.770 ↓ 0.0 0 1

Hash (cost=522.13..522.13 rows=1 width=4) (actual time=1.770..1.770 rows=0 loops=1)

  • Output: tlsos_11."tlsostosID
  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
  • Buffers: shared hit=200
47. 0.002 1.770 ↓ 0.0 0 1

Subquery Scan on tlsos_11 (cost=521.28..522.13 rows=1 width=4) (actual time=1.770..1.770 rows=0 loops=1)

  • Output: tlsos_11."tlsostosID
  • Filter: (tlsos_11.r = 1)
  • Buffers: shared hit=200
48. 0.000 1.768 ↓ 0.0 0 1

WindowAgg (cost=521.28..521.80 rows=26 width=16) (actual time=1.768..1.768 rows=0 loops=1)

  • Output: "TabLogSituacaoOrdemServico_11"."tlsostosID", row_number() OVER (?), "TabLogSituacaoOrdemServico_11"."tlsosID
  • Buffers: shared hit=200
49.          

Initplan (for WindowAgg)

50. 0.011 0.011 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=8) (actual time=0.011..0.011 rows=1 loops=1)

  • Output: ('2020-1-01 00:00:00'::cstring)::timestamp with time zone
51. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.02 rows=1 width=8) (never executed)

  • Output: ((('2020-1-01'::cstring)::date + '1 mon'::interval) - '00:00:01'::interval)
52. 0.013 1.766 ↓ 0.0 0 1

Sort (cost=521.25..521.31 rows=26 width=8) (actual time=1.766..1.766 rows=0 loops=1)

  • Output: "TabLogSituacaoOrdemServico_11"."tlsostosID", "TabLogSituacaoOrdemServico_11"."tlsosID
  • Sort Key: "TabLogSituacaoOrdemServico_11"."tlsostosID", "TabLogSituacaoOrdemServico_11"."tlsosID" DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=200
53. 1.753 1.753 ↓ 0.0 0 1

Seq Scan on public."TabLogSituacaoOrdemServico" "TabLogSituacaoOrdemServico_11" (cost=0.00..520.63 rows=26 width=8) (actual time=1.753..1.753 rows=0 loops=1)

  • Output: "TabLogSituacaoOrdemServico_11"."tlsostosID", "TabLogSituacaoOrdemServico_11"."tlsosID
  • Filter: (("TabLogSituacaoOrdemServico_11"."tlsosDataHora" >= $90) AND ("TabLogSituacaoOrdemServico_11"."tlsosDataHora" <= $91) AND ("TabLogSituacaoOrdemServico_11"."tlsosSituacao" = ANY ('{3,9}'::integer[])))
  • Rows Removed by Filter: 18337
  • Buffers: shared hit=200
54. 0.000 0.000 ↓ 0.0 0

Index Only Scan using "TabOrdemServico_Unique_tosID_tostemID" on public."TabOrdemServico" tos_16 (cost=0.28..0.33 rows=1 width=4) (never executed)