explain.depesz.com

PostgreSQL's explain analyze made readable

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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 10,646.243 11,302.083 ↑ 83.3 12 1

Function Scan on pg_catalog.generate_series mes (cost=11,038.88..77,996,900.41 rows=1,000 width=184) (actual time=1,093.265..11,302.083 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), (SubPlan 35), ((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) - ((SubPlan 44) + COALESCE((SubPlan 47), '0'::double precision))), $87, $97
  • Function Call: generate_series(1, 12)
  • Buffers: shared hit=642128, temp read=10752 written=10752
2.          

Initplan (for Function Scan)

3. 3.010 46.516 ↑ 1.0 1 1

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

  • Output: sum(trp_15."trpValorRecebido")
  • Buffers: shared hit=1405
4. 7.961 43.506 ↓ 85.8 12,695 1

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

  • Output: trp_15."trpValorRecebido
  • Hash Cond: (trp_15."trptrecID" = trec_15."trecID")
  • Buffers: shared hit=1405
5. 31.871 31.871 ↓ 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.037..31.871 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
6. 1.525 3.674 ↓ 1.0 5,354 1

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

  • Output: trec_15."trecID
  • Buckets: 8192 Batches: 1 Memory Usage: 253kB
  • Buffers: shared hit=96
7. 2.149 2.149 ↓ 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.005..2.149 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
8. 0.286 65.820 ↑ 1.0 1 1

Aggregate (cost=8,360.37..8,360.39 rows=1 width=8) (actual time=65.820..65.820 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
9.          

Initplan (for Aggregate)

10. 0.031 30.298 ↑ 1.0 1 1

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

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

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

  • Output: trp_1_5."trpValorParcela", trp_1_5."trpDesconto
  • Buffers: shared hit=1428
12. 26.451 30.264 ↓ 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=30.264..30.264 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
13. 3.813 3.813 ↓ 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.813..3.813 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
14. 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[]))
15. 0.008 1.755 ↑ 1.0 1 1

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

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

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

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

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

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

Hash Join (cost=522.14..716.46 rows=1 width=12) (actual time=1.744..1.744 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
19. 0.011 0.011 ↑ 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.011 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
20. 0.002 1.716 ↓ 0.0 0 1

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

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

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

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

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

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

Initplan (for WindowAgg)

24. 0.012 0.012 ↑ 1.0 1 1

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

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

Seq Scan on public."TabLogSituacaoOrdemServico" "TabLogSituacaoOrdemServico_11" (cost=0.00..520.63 rows=26 width=8) (actual time=1.699..1.700 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
28. 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)

  • Output: tos_16."tosID", tos_16."tostemID
  • Index Cond: (tos_16."tosID" = trec_16."trectosID")
  • Filter: (tos_16."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_16 (cost=0.29..1.47 rows=1 width=20) (never executed)

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

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

  • Output: trp_17."trpValorParcela", trp_17."trpDesconto
  • Buffers: shared hit=5137
31. 0.751 31.441 ↓ 763.0 763 1

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

  • Output: trec_17."trectosID", trp_17."trpValorParcela", trp_17."trpDesconto
  • Buffers: shared hit=3603
32. 29.164 29.164 ↓ 763.0 763 1

Seq Scan on public."TabReceitaParcela" trp_17 (cost=0.00..2,901.30 rows=1 width=20) (actual time=0.214..29.164 rows=763 loops=1)

  • Output: trp_17."trpID", trp_17."trpValorParcela", trp_17."trpPago", trp_17."trpDesconto", trp_17."trpDataVencimento", trp_17."trptrecID", trp_17."trpMulta", trp_17."trpDataRecebimento", trp_17."trpSubstituida", trp_17."trpParcelaSubstitutaID", trp_17."trpBaixada", trp_17."trpTipoBaixa", trp_17."trpTipoDocumento", trp_17."trpNumDocumento", trp_17."trpNumeroParcela", trp_17."trptcbID", trp_17."trpDataBaixa", trp_17."trpJuros", trp_17."trpSubstituta", trp_17."trpObservacao", trp_17."trpEmitidoRemessa", trp_17."trpDataRemessa", trp_17."trptcoconID", trp_17."trpPagoParcial", trp_17."trptrpOriundaID", trp_17."trpValorRecebido", trp_17."trpEmCobranca", trp_17."trpNossoNumero", trp_17."trptremID", trp_17."trpObservacaoBaixa", trp_17."trpObservacaoSubstituicao", trp_17."trpIsExcluido", trp_17."trpEmiteNFSe", trp_17."trpDataCompensacao", trp_17."trpEmitidoNFSe", trp_17."trpImpostoRetido", trp_17."trpDataDisponibilidade", trp_17."trptcfosID", trp_17."trpIsEntrada
  • Filter: ((trp_17."trpBaixada" IS FALSE) AND (trp_17."trpSubstituida" IS FALSE) AND (NOT trp_17."trpIsExcluido") AND (date_part('month'::text, (trp_17."trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (date_part('year'::text, (trp_17."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_17 (cost=0.28..8.30 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=763)

  • Output: trec_17."trecID", trec_17."trectclID", trec_17."trecCondicaoPagamento", trec_17."trecDataCompetencia", trec_17."trecObservacao", trec_17."trectemID", trec_17."trectosID", trec_17."trectrosID", trec_17."trectfuID", trec_17."trectfoID", trec_17."trecRecurrentBilling
  • Index Cond: (trec_17."trecID" = trp_17."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_17 (cost=0.28..0.33 rows=1 width=4) (actual time=0.001..0.002 rows=1 loops=763)

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

SubPlan (for Function Scan)

36. 5.844 514.404 ↑ 1.0 1 12

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

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

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

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

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

WindowAgg (cost=813.07..935.21 rows=6,107 width=20) (actual time=14.010..30.036 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.096 0.096 ↑ 1.0 1 12

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

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

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

Seq Scan on public."TabLogSituacaoOrdemServico" (cost=0.00..429.02 rows=6,107 width=12) (actual time=0.016..5.615 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.228 29.100 ↑ 1.0 1 12

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

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

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

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

Subquery Scan on tlsos_1 (cost=521.30..522.15 rows=1 width=4) (actual time=2.066..2.214 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.876 26.028 ↓ 3.5 90 12

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

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

Initplan (for WindowAgg)

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.005..0.006 rows=1 loops=8)

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

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

Seq Scan on public."TabLogSituacaoOrdemServico" "TabLogSituacaoOrdemServico_1" (cost=0.00..520.63 rows=26 width=8) (actual time=1.572..2.002 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