explain.depesz.com

PostgreSQL's explain analyze made readable

Result: loZG : 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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 6,150.598 6,825.442 ↑ 83.3 12 1

Function Scan on pg_catalog.generate_series mes (cost=11,038.88..42,335,022.38 rows=1,000 width=160) (actual time=663.093..6,825.442 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), (SubPlan 27), (SubPlan 28), COALESCE((SubPlan 29), '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, $53, $63
  • Function Call: generate_series(1, 12)
  • Buffers: shared hit=353902, temp read=6732 written=6732
2.          

Initplan (for Function Scan)

3. 2.999 47.054 ↑ 1.0 1 1

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

  • Output: sum(trp_7."trpValorRecebido")
  • Buffers: shared hit=1405
4. 7.998 44.055 ↓ 85.8 12,695 1

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

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

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

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

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

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

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

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

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

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

Initplan (for Aggregate)

10. 0.013 25.681 ↑ 1.0 1 1

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

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

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

  • Output: trp_1_3."trpValorParcela", trp_1_3."trpDesconto
  • Buffers: shared hit=1428
12. 21.786 25.666 ↓ 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=25.666..25.666 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. 3.880 3.880 ↓ 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.880..3.880 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.009 1.806 ↑ 1.0 1 1

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

  • Output: (sum(trp_8."trpValorParcela") - sum(trp_8."trpDesconto"))
  • Buffers: shared hit=201
16. 0.001 1.797 ↓ 0.0 0 1

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

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

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

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

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

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

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

  • Output: trec_8."trecID", trec_8."trectclID", trec_8."trecCondicaoPagamento", trec_8."trecDataCompetencia", trec_8."trecObservacao", trec_8."trectemID", trec_8."trectosID", trec_8."trectrosID", trec_8."trectfuID", trec_8."trectfoID", trec_8."trecRecurrentBilling
  • Buffers: shared hit=1
20. 0.001 1.756 ↓ 0.0 0 1

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

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

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

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

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

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

Initplan (for WindowAgg)

24. 0.014 0.014 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=8) (actual time=0.014..0.014 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 1.752 ↓ 0.0 0 1

Sort (cost=521.25..521.31 rows=26 width=8) (actual time=1.752..1.752 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. 1.740 1.740 ↓ 0.0 0 1

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

  • Output: "TabLogSituacaoOrdemServico_8"."tlsostosID", "TabLogSituacaoOrdemServico_8"."tlsosID
  • Filter: (("TabLogSituacaoOrdemServico_8"."tlsosDataHora" >= $56) AND ("TabLogSituacaoOrdemServico_8"."tlsosDataHora" <= $57) 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_8."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_8 (cost=0.29..1.47 rows=1 width=20) (never executed)

  • 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
  • Index Cond: ((trp_8."trptrecID" = trec_8."trecID") AND (trp_8."trpSubstituida" = false))
  • Filter: ((trp_8."trpBaixada" IS FALSE) AND (trp_8."trpSubstituida" IS FALSE) AND (NOT trp_8."trpIsExcluido") AND (date_part('month'::text, COALESCE((trp_8."trpDataCompensacao")::timestamp with time zone, trp_8."trpDataRecebimento")) = '1'::double precision) AND (date_part('year'::text, COALESCE((trp_8."trpDataCompensacao")::timestamp with time zone, trp_8."trpDataRecebimento")) = '2020'::double precision))
30. 0.449 31.135 ↓ 762.0 762 1

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

  • Output: trp_9."trpValorParcela", trp_9."trpDesconto
  • Buffers: shared hit=5137
31. 0.769 29.160 ↓ 763.0 763 1

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

  • Output: trec_9."trectosID", trp_9."trpValorParcela", trp_9."trpDesconto
  • Buffers: shared hit=3603
32. 26.865 26.865 ↓ 763.0 763 1

Seq Scan on public."TabReceitaParcela" trp_9 (cost=0.00..2,901.30 rows=1 width=20) (actual time=0.207..26.865 rows=763 loops=1)

  • 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
  • Filter: ((trp_9."trpBaixada" IS FALSE) AND (trp_9."trpSubstituida" IS FALSE) AND (NOT trp_9."trpIsExcluido") AND (date_part('month'::text, (trp_9."trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (date_part('year'::text, (trp_9."trpDataVencimento")::timestamp without time zone) = '2020'::double precision))
  • Rows Removed by Filter: 62892
  • Buffers: shared hit=1309
33. 1.526 1.526 ↑ 1.0 1 763

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

  • 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=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_9."trectosID")
  • Filter: (tos_12."tostemID" = ANY ('{5,1}'::integer[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 0
  • Buffers: shared hit=1534
35.          

SubPlan (for Function Scan)

36. 5.748 520.524 ↑ 1.0 1 12

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

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

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

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

Subquery Scan on tlsos (cost=813.07..1,026.82 rows=9 width=4) (actual time=14.136..36.013 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. 147.924 369.984 ↓ 2.7 16,739 12

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

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

Initplan (for WindowAgg)

41. 0.168 0.168 ↑ 1.0 1 12

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

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

Sort (cost=813.04..828.31 rows=6,107 width=12) (actual time=14.044..18.491 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. 68.688 68.688 ↓ 2.7 16,739 12

Seq Scan on public."TabLogSituacaoOrdemServico" (cost=0.00..429.02 rows=6,107 width=12) (actual time=0.023..5.724 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. 39.232 39.232 ↑ 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.001..0.001 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.168 48.324 ↑ 1.0 1 12

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

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

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

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

Subquery Scan on tlsos_1 (cost=521.30..522.15 rows=1 width=4) (actual time=1.955..2.098 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.836 24.636 ↓ 3.5 90 12

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

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

Initplan (for WindowAgg)

50. 0.132 0.132 ↑ 1.0 1 12

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

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

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

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

Sort (cost=521.25..521.31 rows=26 width=8) (actual time=1.947..1.969 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. 22.752 22.752 ↓ 3.5 90 12

Seq Scan on public."TabLogSituacaoOrdemServico" "TabLogSituacaoOrdemServico_1" (cost=0.00..520.63 rows=26 width=8) (actual time=1.471..1.896 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. 22.596 22.596 ↑ 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.020..0.021 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