explain.depesz.com

PostgreSQL's explain analyze made readable

Result: N27E : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: plan #3o9f; plan #J9Xm; plan #1yS; plan #4JiL; plan #8kFk; plan #HHSh; plan #kGXZ; plan #SrnL; plan #loZG

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 7,407.161 8,331.481 ↑ 83.3 12 1

Function Scan on pg_catalog.generate_series mes (cost=11,038.88..45,157,989.88 rows=1,000 width=160) (actual time=1,434.601..8,331.481 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), ((((SubPlan 26) * '100'::double precision) / (SubPlan 29)) - '100'::double precision), (SubPlan 30), (SubPlan 31), COALESCE((SubPlan 32), '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, $56, $66
  • Function Call: generate_series(1, 12)
  • Buffers: shared hit=369706, temp read=6732 written=6732
2.          

Initplan (forFunction Scan)

3. 15.061 100.804 ↑ 1.0 1 1

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

  • Output: sum(trp_8."trpValorRecebido")
  • Buffers: shared hit=1405
4. 12.266 85.743 ↓ 85.8 12,695 1

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

  • Output: trp_8."trpValorRecebido
  • Hash Cond: (trp_8."trptrecID" = trec_8."trecID")
  • Buffers: shared hit=1405
5. 65.495 65.495 ↓ 78.8 15,593 1

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

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

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

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

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

  • Output: trec_8."trecID
  • Filter: (trec_8."trectemID" = ANY ('{1,2}'::integer[]))
  • Rows Removed by Filter: 1799
  • Buffers: shared hit=96
8. 0.307 120.100 ↑ 1.0 1 1

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

  • Output: (((sum(trp_10."trpValorParcela") - sum(trp_10."trpDesconto")) - COALESCE($58, '0'::double precision)) - COALESCE($63, '0'::double precision))
  • Buffers: shared hit=6766
9.          

Initplan (forAggregate)

10. 0.026 54.717 ↑ 1.0 1 1

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

  • Output: (sum(trp_1_3."trpValorParcela") - sum(trp_1_3."trpDesconto"))
  • Buffers: shared hit=1428
11. 0.002 54.691 ↓ 0.0 0 1

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

  • Output: trp_1_3."trpValorParcela", trp_1_3."trpDesconto
  • Buffers: shared hit=1428
12. 46.810 54.689 ↓ 0.0 0 1

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

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

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

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

  • Output: trec_1_3."trecID", trec_1_3."trectclID", trec_1_3."trecCondicaoPagamento", trec_1_3."trecDataCompetencia", trec_1_3."trecObservacao", trec_1_3."trectemID", trec_1_3."trectosID", trec_1_3."trectrosID", trec_1_3."trectfuID", trec_1_3."trectfoID", trec_1_3."trecRecurrentBilling
  • Index Cond: (trec_1_3."trecID" = trp_1_3."trptrecID")
  • Filter: (trec_1_3."trectemID" = ANY ('{5,1}'::integer[]))
15. 0.017 6.641 ↑ 1.0 1 1

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

  • Output: (sum(trp_9."trpValorParcela") - sum(trp_9."trpDesconto"))
  • Buffers: shared hit=201
16. 0.002 6.624 ↓ 0.0 0 1

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

  • Output: trp_9."trpValorParcela", trp_9."trpDesconto
  • Buffers: shared hit=201
17. 0.000 6.622 ↓ 0.0 0 1

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

  • Output: trec_9."trecID
  • Join Filter: (tlsos_8."tlsostosID" = tos_11."tosID")
  • Buffers: shared hit=201
18. 0.019 6.623 ↓ 0.0 0 1

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

  • Output: tlsos_8."tlsostosID", trec_9."trectosID", trec_9."trecID
  • Hash Cond: (trec_9."trectosID" = tlsos_8."tlsostosID")
  • Buffers: shared hit=201
19. 0.008 0.008 ↑ 7,150.0 1 1

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

  • 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
  • Buffers: shared hit=1
20. 0.000 6.596 ↓ 0.0 0 1

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

  • Output: tlsos_8."tlsostosID
  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
  • Buffers: shared hit=200
21. 0.002 6.596 ↓ 0.0 0 1

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

  • Output: tlsos_8."tlsostosID
  • Filter: (tlsos_8.r = 1)
  • Buffers: shared hit=200
22. 0.000 6.594 ↓ 0.0 0 1

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

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

Initplan (forWindowAgg)

24. 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
25. 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)
26. 0.012 6.593 ↓ 0.0 0 1

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

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

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

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

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

  • Output: tos_11."tosID", tos_11."tostemID
  • Index Cond: (tos_11."tosID" = trec_9."trectosID")
  • Filter: (tos_11."tostemID" = ANY ('{5,1}'::integer[]))
  • Heap Fetches: 0
29. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_trp_trecid_trpsubstituida on public."TabReceitaParcela" trp_9 (cost=0.29..1.47 rows=1 width=20) (never executed)

  • Output: trp_9."trpID", trp_9."trpValorParcela", trp_9."trpPago", trp_9."trpDesconto", trp_9."trpDataVencimento", trp_9."trptrecID", trp_9."trpMulta", trp_9."trpDataRecebimento", trp_9."trpSubstituida", trp_9."trpParcelaSubstitutaID", trp_9."trpBaixada", trp_9."trpTipoBaixa", trp_9."trpTipoDocumento", trp_9."trpNumDocumento", trp_9."trpNumeroParcela", trp_9."trptcbID", trp_9."trpDataBaixa", trp_9."trpJuros", trp_9."trpSubstituta", trp_9."trpObservacao", trp_9."trpEmitidoRemessa", trp_9."trpDataRemessa", trp_9."trptcoconID", trp_9."trpPagoParcial", trp_9."trptrpOriundaID", trp_9."trpValorRecebido", trp_9."trpEmCobranca", trp_9."trpNossoNumero", trp_9."trptremID", trp_9."trpObservacaoBaixa", trp_9."trpObservacaoSubstituicao", trp_9."trpIsExcluido", trp_9."trpEmiteNFSe", trp_9."trpDataCompensacao", trp_9."trpEmitidoNFSe", trp_9."trpImpostoRetido", trp_9."trpDataDisponibilidade", trp_9."trptcfosID", trp_9."trpIsEntrada
  • Index Cond: ((trp_9."trptrecID" = trec_9."trecID") AND (trp_9."trpSubstituida" = false))
  • Filter: ((trp_9."trpBaixada" IS FALSE) AND (trp_9."trpSubstituida" IS FALSE) AND (NOT trp_9."trpIsExcluido") AND (date_part('month'::text, COALESCE((trp_9."trpDataCompensacao")::timestamp with time zone, trp_9."trpDataRecebimento")) = '1'::double precision) AND (date_part('year'::text, COALESCE((trp_9."trpDataCompensacao")::timestamp with time zone, trp_9."trpDataRecebimento")) = '2020'::double precision))
30. 0.504 58.435 ↓ 762.0 762 1

Nested Loop (cost=0.56..2,909.95 rows=1 width=16) (actual time=0.241..58.435 rows=762 loops=1)

  • Output: trp_10."trpValorParcela", trp_10."trpDesconto
  • Buffers: shared hit=5137
31. 1.171 56.405 ↓ 763.0 763 1

Nested Loop (cost=0.28..2,909.61 rows=1 width=20) (actual time=0.226..56.405 rows=763 loops=1)

  • Output: trec_10."trectosID", trp_10."trpValorParcela", trp_10."trpDesconto
  • Buffers: shared hit=3603
32. 46.078 46.078 ↓ 763.0 763 1

Seq Scan on public."TabReceitaParcela" trp_10 (cost=0.00..2,901.30 rows=1 width=20) (actual time=0.213..46.078 rows=763 loops=1)

  • Output: trp_10."trpID", trp_10."trpValorParcela", trp_10."trpPago", trp_10."trpDesconto", trp_10."trpDataVencimento", trp_10."trptrecID", trp_10."trpMulta", trp_10."trpDataRecebimento", trp_10."trpSubstituida", trp_10."trpParcelaSubstitutaID", trp_10."trpBaixada", trp_10."trpTipoBaixa", trp_10."trpTipoDocumento", trp_10."trpNumDocumento", trp_10."trpNumeroParcela", trp_10."trptcbID", trp_10."trpDataBaixa", trp_10."trpJuros", trp_10."trpSubstituta", trp_10."trpObservacao", trp_10."trpEmitidoRemessa", trp_10."trpDataRemessa", trp_10."trptcoconID", trp_10."trpPagoParcial", trp_10."trptrpOriundaID", trp_10."trpValorRecebido", trp_10."trpEmCobranca", trp_10."trpNossoNumero", trp_10."trptremID", trp_10."trpObservacaoBaixa", trp_10."trpObservacaoSubstituicao", trp_10."trpIsExcluido", trp_10."trpEmiteNFSe", trp_10."trpDataCompensacao", trp_10."trpEmitidoNFSe", trp_10."trpImpostoRetido", trp_10."trpDataDisponibilidade", trp_10."trptcfosID", trp_10."trpIsEntrada
  • Filter: ((trp_10."trpBaixada" IS FALSE) AND (trp_10."trpSubstituida" IS FALSE) AND (NOT trp_10."trpIsExcluido") AND (date_part('month'::text, (trp_10."trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (date_part('year'::text, (trp_10."trpDataVencimento")::timestamp without time zone) = '2020'::double precision))
  • Rows Removed by Filter: 62892
  • Buffers: shared hit=1309
33. 9.156 9.156 ↑ 1.0 1 763

Index Scan using "TabReceita_trecID" on public."TabReceita" trec_10 (cost=0.28..8.30 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=763)

  • Output: trec_10."trecID", trec_10."trectclID", trec_10."trecCondicaoPagamento", trec_10."trecDataCompetencia", trec_10."trecObservacao", trec_10."trectemID", trec_10."trectosID", trec_10."trectrosID", trec_10."trectfuID", trec_10."trectfoID", trec_10."trecRecurrentBilling
  • Index Cond: (trec_10."trecID" = trp_10."trptrecID")
  • Buffers: shared hit=2294
34. 1.526 1.526 ↑ 1.0 1 763

Index Only Scan using "TabOrdemServico_Unique_tosID_tostemID" on public."TabOrdemServico" tos_12 (cost=0.28..0.33 rows=1 width=4) (actual time=0.001..0.002 rows=1 loops=763)

  • Output: tos_12."tosID", tos_12."tostemID
  • Index Cond: (tos_12."tosID" = trec_10."trectosID")
  • Filter: (tos_12."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 0
  • Buffers: shared hit=1534
35.          

SubPlan (forFunction Scan)

36. 6.924 662.244 ↑ 1.0 1 12

Aggregate (cost=1,065.64..1,065.65 rows=1 width=8) (actual time=55.187..55.187 rows=1 loops=12)

  • Output: count(tos."tosID")
  • Buffers: shared hit=81170
37. 37.888 655.320 ↓ 364.6 1,823 12

Nested Loop (cost=813.35..1,065.63 rows=5 width=4) (actual time=18.053..54.610 rows=1,823 loops=12)

  • Output: tos."tosID
  • Buffers: shared hit=81170
38. 83.700 538.968 ↓ 363.2 3,269 12

Subquery Scan on tlsos (cost=813.07..1,026.82 rows=9 width=4) (actual time=18.038..44.914 rows=3,269 loops=12)

  • Output: tlsos."tlsostosID", tlsos."tlsosSituacao", tlsos.r, "TabLogSituacaoOrdemServico"."tlsosID
  • Filter: ((tlsos."tlsosSituacao" = ANY ('{3,9}'::integer[])) AND (tlsos.r = 1))
  • Rows Removed by Filter: 13469
  • Buffers: shared hit=2400
39. 177.876 455.268 ↓ 2.7 16,739 12

WindowAgg (cost=813.07..935.21 rows=6,107 width=20) (actual time=18.021..37.939 rows=16,739 loops=12)

  • Output: "TabLogSituacaoOrdemServico"."tlsostosID", "TabLogSituacaoOrdemServico"."tlsosSituacao", row_number() OVER (?), "TabLogSituacaoOrdemServico"."tlsosID
  • Buffers: shared hit=2400
40.          

Initplan (forWindowAgg)

41. 0.156 0.156 ↑ 1.0 1 12

Result (cost=0.00..0.03 rows=1 width=8) (actual time=0.012..0.013 rows=1 loops=12)

  • Output: date_trunc('month'::text, (((('2019-'::text || (mes.mes)::text) || '-01'::text))::date)::timestamp with time zone)
42. 185.076 277.236 ↓ 2.7 16,739 12

Sort (cost=813.04..828.31 rows=6,107 width=12) (actual time=18.002..23.103 rows=16,739 loops=12)

  • Output: "TabLogSituacaoOrdemServico"."tlsostosID", "TabLogSituacaoOrdemServico"."tlsosID", "TabLogSituacaoOrdemServico"."tlsosSituacao
  • Sort Key: "TabLogSituacaoOrdemServico"."tlsostosID", "TabLogSituacaoOrdemServico"."tlsosID" DESC
  • Sort Method: quicksort Memory: 1628kB
  • Buffers: shared hit=2400
43. 92.160 92.160 ↓ 2.7 16,739 12

Seq Scan on public."TabLogSituacaoOrdemServico" (cost=0.00..429.02 rows=6,107 width=12) (actual time=0.021..7.680 rows=16,739 loops=12)

  • Output: "TabLogSituacaoOrdemServico"."tlsostosID", "TabLogSituacaoOrdemServico"."tlsosID", "TabLogSituacaoOrdemServico"."tlsosSituacao
  • Filter: ("TabLogSituacaoOrdemServico"."tlsosDataHora" < $1)
  • Rows Removed by Filter: 1598
  • Buffers: shared hit=2400
44. 78.464 78.464 ↑ 1.0 1 39,232

Index Only Scan using "TabOrdemServico_Unique_tosID_tostemID" on public."TabOrdemServico" tos (cost=0.28..4.30 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=39,232)

  • Output: tos."tosID", tos."tostemID
  • Index Cond: (tos."tosID" = tlsos."tlsostosID")
  • Filter: (tos."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 4
  • Buffers: shared hit=78770
45. 0.216 41.172 ↑ 1.0 1 12

Aggregate (cost=526.46..526.47 rows=1 width=8) (actual time=3.430..3.431 rows=1 loops=12)

  • Output: count(tos_1."tosID")
  • Buffers: shared hit=4563
46. 1.156 40.956 ↓ 47.0 47 12

Nested Loop (cost=521.58..526.46 rows=1 width=4) (actual time=3.084..3.413 rows=47 loops=12)

  • Output: tos_1."tosID
  • Buffers: shared hit=4563
47. 0.552 38.724 ↓ 90.0 90 12

Subquery Scan on tlsos_1 (cost=521.30..522.15 rows=1 width=4) (actual time=3.078..3.227 rows=90 loops=12)

  • Output: tlsos_1."tlsostosID", tlsos_1.r, "TabLogSituacaoOrdemServico_1"."tlsosID
  • Filter: (tlsos_1.r = 1)
  • Rows Removed by Filter: 0
  • Buffers: shared hit=2400
48. 0.852 38.172 ↓ 3.5 90 12

WindowAgg (cost=521.30..521.82 rows=26 width=16) (actual time=3.074..3.181 rows=90 loops=12)

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

Initplan (forWindowAgg)

50. 0.144 0.144 ↑ 1.0 1 12

Result (cost=0.00..0.03 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=12)

  • Output: ((('2019-'::text || (mes.mes)::text) || '-01 00:00:00'::text))::timestamp with time zone
51. 0.048 0.048 ↑ 1.0 1 8

Result (cost=0.00..0.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=8)

  • Output: ((((('2019-'::text || (mes.mes)::text) || '-01'::text))::date + '1 mon'::interval) - '00:00:01'::interval)
52. 0.924 37.128 ↓ 3.5 90 12

Sort (cost=521.25..521.31 rows=26 width=8) (actual time=3.069..3.094 rows=90 loops=12)

  • Output: "TabLogSituacaoOrdemServico_1"."tlsostosID", "TabLogSituacaoOrdemServico_1"."tlsosID
  • Sort Key: "TabLogSituacaoOrdemServico_1"."tlsostosID", "TabLogSituacaoOrdemServico_1"."tlsosID" DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=2400
53. 36.204 36.204 ↓ 3.5 90 12

Seq Scan on public."TabLogSituacaoOrdemServico" "TabLogSituacaoOrdemServico_1" (cost=0.00..520.63 rows=26 width=8) (actual time=2.258..3.017 rows=90 loops=12)

  • Output: "TabLogSituacaoOrdemServico_1"."tlsostosID", "TabLogSituacaoOrdemServico_1"."tlsosID
  • Filter: (("TabLogSituacaoOrdemServico_1"."tlsosDataHora" >= $4) AND ("TabLogSituacaoOrdemServico_1"."tlsosDataHora" <= $5) AND ("TabLogSituacaoOrdemServico_1"."tlsosSituacao" = 3))
  • Rows Removed by Filter: 18247
  • Buffers: shared hit=2400
54. 1.076 1.076 ↑ 1.0 1 1,076

Index Only Scan using "TabOrdemServico_Unique_tosID_tostemID" on public."TabOrdemServico" tos_1 (cost=0.28..4.30 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1,076)

  • Output: tos_1."tosID", tos_1."tostemID
  • Index Cond: (tos_1."tosID" = tlsos_1."tlsostosID")
  • Filter: (tos_1."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 1
  • Buffers: shared hit=2163