explain.depesz.com

PostgreSQL's explain analyze made readable

Result: oHvx : Optimization for: Optimization for: Optimization for: Optimization for: plan #CI54; plan #Pkg6; plan #xoV0; plan #tUI3

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.090 585.554 ↑ 1.3 35 1

GroupAggregate (cost=41,577.14..41,580.31 rows=47 width=92) (actual time=585.471..585.554 rows=35 loops=1)

  • Group Key: t."tasID", t."tasDescricao", t.mes, t."tostemID
2. 0.089 585.464 ↓ 1.3 60 1

Sort (cost=41,577.14..41,577.25 rows=47 width=84) (actual time=585.451..585.464 rows=60 loops=1)

  • Sort Key: t."tasID", t."tasDescricao", t.mes, t."tostemID
  • Sort Method: quicksort Memory: 33kB
3. 0.044 585.375 ↓ 1.3 60 1

Subquery Scan on t (cost=2,249.84..41,575.83 rows=47 width=84) (actual time=109.262..585.375 rows=60 loops=1)

4. 0.035 585.331 ↓ 1.3 60 1

Append (cost=2,249.84..41,575.36 rows=47 width=84) (actual time=109.260..585.331 rows=60 loops=1)

5. 1.295 585.186 ↓ 2.3 25 1

GroupAggregate (cost=2,249.84..41,542.12 rows=11 width=89) (actual time=109.258..585.186 rows=25 loops=1)

  • Group Key: tas."tasID", tos."tostemID
6. 1.121 57.316 ↓ 137.5 1,513 1

Sort (cost=2,249.84..2,249.87 rows=11 width=49) (actual time=56.862..57.316 rows=1,513 loops=1)

  • Sort Key: tas."tasID
  • Sort Method: quicksort Memory: 189kB
7. 1.938 56.195 ↓ 137.5 1,513 1

Nested Loop (cost=0.99..2,249.65 rows=11 width=49) (actual time=0.059..56.195 rows=1,513 loops=1)

8. 1.452 52.744 ↓ 137.5 1,513 1

Nested Loop (cost=0.85..2,247.60 rows=11 width=12) (actual time=0.056..52.744 rows=1,513 loops=1)

9. 0.963 48.266 ↓ 137.5 1,513 1

Nested Loop (cost=0.57..2,230.41 rows=11 width=12) (actual time=0.053..48.266 rows=1,513 loops=1)

10. 4.553 41.769 ↓ 131.8 2,767 1

Subquery Scan on tlsos (cost=0.29..2,071.85 rows=21 width=4) (actual time=0.047..41.769 rows=2,767 loops=1)

  • Filter: ((tlsos."tlsosSituacao" = ANY ('{3,9}'::integer[])) AND (tlsos.r = 1))
  • Rows Removed by Filter: 11487
11. 11.632 37.216 ↑ 1.0 14,254 1

WindowAgg (cost=0.29..1,854.97 rows=14,459 width=68) (actual time=0.023..37.216 rows=14,254 loops=1)

12. 25.584 25.584 ↑ 1.0 14,254 1

Index Scan using idx_tlsos_tlsostosdesc on "TabLogSituacaoOrdemServico" (cost=0.29..1,601.93 rows=14,459 width=12) (actual time=0.019..25.584 rows=14,254 loops=1)

  • Filter: ("tlsosDataHora" < (date_trunc('month'::text, (('2019-1-1'::cstring)::date)::timestamp with time zone) + '1 mon -00:00:01'::interval))
  • Rows Removed by Filter: 6826
13. 5.534 5.534 ↑ 1.0 1 2,767

Index Scan using "TabOrdemServico_Unique_tosID_tostemID" on "TabOrdemServico" tos (cost=0.28..7.54 rows=1 width=12) (actual time=0.001..0.002 rows=1 loops=2,767)

  • Index Cond: (("tosID" = tlsos."tlsostosID") AND ("tostemID" = 1))
14. 3.026 3.026 ↑ 1.0 1 1,513

Index Scan using "TabPropostaComercial_tpcID" on "TabPropostaComercial" tpc (cost=0.28..1.55 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,513)

  • Index Cond: ("tpcID" = tos."tostpcID")
15. 1.513 1.513 ↑ 1.0 1 1,513

Index Scan using "TabAssessoria_tasID" on "TabAssessoria" tas (cost=0.14..0.18 rows=1 width=41) (actual time=0.001..0.001 rows=1 loops=1,513)

  • Index Cond: ("tasID" = tpc."tpctasID")
16.          

SubPlan (for GroupAggregate)

17. 0.475 134.025 ↑ 1.0 1 25

Aggregate (cost=892.99..893.00 rows=1 width=8) (actual time=5.361..5.361 rows=1 loops=25)

18. 3.845 133.550 ↓ 47.0 47 25

Nested Loop (cost=4.52..892.98 rows=1 width=16) (actual time=0.793..5.342 rows=47 loops=25)

19. 85.275 85.275 ↓ 8.4 118 25

Seq Scan on "TabReceita" trec (cost=0.00..291.29 rows=14 width=4) (actual time=0.246..3.411 rows=118 loops=25)

  • Filter: ("trectosID" = ANY (array_agg(DISTINCT tos."tosID")))
  • Rows Removed by Filter: 8048
20. 35.544 44.430 ↓ 0.0 0 2,962

Bitmap Heap Scan on "TabReceitaParcela" trp (cost=4.52..42.97 rows=1 width=20) (actual time=0.013..0.015 rows=0 loops=2,962)

  • Recheck Cond: ("trptrecID" = trec."trecID")
  • Filter: (("trpSubstituida" IS FALSE) AND ("trpBaixada" IS FALSE) AND (NOT "trpIsExcluido") AND (date_part('month'::text, ("trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (date_part('year'::text, ("trpDataVencimento")::timestamp without time zone) = '2019'::double precision))
  • Rows Removed by Filter: 11
  • Heap Blocks: exact=22340
21. 8.886 8.886 ↓ 1.1 11 2,962

Bitmap Index Scan on idx_trp_trecid_trpsubstituida (cost=0.00..4.52 rows=10 width=0) (actual time=0.003..0.003 rows=11 loops=2,962)

  • Index Cond: (("trptrecID" = trec."trecID") AND ("trpSubstituida" = false))
22. 0.400 131.750 ↑ 1.0 1 25

Aggregate (cost=892.99..893.00 rows=1 width=8) (actual time=5.270..5.270 rows=1 loops=25)

23. 2.133 131.350 ↓ 47.0 47 25

Nested Loop (cost=4.52..892.98 rows=1 width=8) (actual time=0.793..5.254 rows=47 loops=25)

24. 81.825 81.825 ↓ 8.4 118 25

Seq Scan on "TabReceita" trec_1 (cost=0.00..291.29 rows=14 width=4) (actual time=0.243..3.273 rows=118 loops=25)

  • Filter: ("trectosID" = ANY (array_agg(DISTINCT tos."tosID")))
  • Rows Removed by Filter: 8048
25. 38.506 47.392 ↓ 0.0 0 2,962

Bitmap Heap Scan on "TabReceitaParcela" trp_1 (cost=4.52..42.97 rows=1 width=12) (actual time=0.014..0.016 rows=0 loops=2,962)

  • Recheck Cond: ("trptrecID" = trec_1."trecID")
  • Filter: (("trpSubstituida" IS FALSE) AND ("trpBaixada" IS FALSE) AND (NOT "trpIsExcluido") AND (date_part('month'::text, COALESCE(("trpDataCompensacao")::timestamp with time zone, "trpDataRecebimento")) = '1'::double precision) AND (date_part('year'::text, COALESCE(("trpDataCompensacao")::timestamp with time zone, "trpDataRecebimento")) = '2019'::double precision))
  • Rows Removed by Filter: 11
  • Heap Blocks: exact=22340
26. 8.886 8.886 ↓ 1.1 11 2,962

Bitmap Index Scan on idx_trp_trecid_trpsubstituida (cost=0.00..4.52 rows=10 width=0) (actual time=0.003..0.003 rows=11 loops=2,962)

  • Index Cond: (("trptrecID" = trec_1."trecID") AND ("trpSubstituida" = false))
27. 0.425 131.825 ↑ 1.0 1 25

Aggregate (cost=892.99..893.00 rows=1 width=8) (actual time=5.272..5.273 rows=1 loops=25)

28. 2.508 131.400 ↓ 47.0 47 25

Nested Loop (cost=4.52..892.98 rows=1 width=4) (actual time=0.780..5.256 rows=47 loops=25)

29. 81.500 81.500 ↓ 8.4 118 25

Seq Scan on "TabReceita" trec_2 (cost=0.00..291.29 rows=14 width=4) (actual time=0.243..3.260 rows=118 loops=25)

  • Filter: ("trectosID" = ANY (array_agg(DISTINCT tos."tosID")))
  • Rows Removed by Filter: 8048
30. 38.506 47.392 ↓ 0.0 0 2,962

Bitmap Heap Scan on "TabReceitaParcela" trp_2 (cost=4.52..42.97 rows=1 width=8) (actual time=0.014..0.016 rows=0 loops=2,962)

  • Recheck Cond: ("trptrecID" = trec_2."trecID")
  • Filter: (("trpSubstituida" IS FALSE) AND ("trpBaixada" IS FALSE) AND (NOT "trpIsExcluido") AND (date_part('month'::text, COALESCE(("trpDataCompensacao")::timestamp with time zone, "trpDataRecebimento")) = '1'::double precision) AND (date_part('year'::text, COALESCE(("trpDataCompensacao")::timestamp with time zone, "trpDataRecebimento")) = '2019'::double precision))
  • Rows Removed by Filter: 11
  • Heap Blocks: exact=22340
31. 8.886 8.886 ↓ 1.1 11 2,962

Bitmap Index Scan on idx_trp_trecid_trpsubstituida (cost=0.00..4.52 rows=10 width=0) (actual time=0.003..0.003 rows=11 loops=2,962)

  • Index Cond: (("trptrecID" = trec_2."trecID") AND ("trpSubstituida" = false))
32. 0.400 128.975 ↑ 1.0 1 25

Aggregate (cost=892.99..893.00 rows=1 width=8) (actual time=5.159..5.159 rows=1 loops=25)

33. 3.707 128.575 ↓ 47.0 47 25

Nested Loop (cost=4.52..892.98 rows=1 width=4) (actual time=0.775..5.143 rows=47 loops=25)

34. 83.400 83.400 ↓ 8.4 118 25

Seq Scan on "TabReceita" trec_3 (cost=0.00..291.29 rows=14 width=4) (actual time=0.247..3.336 rows=118 loops=25)

  • Filter: ("trectosID" = ANY (array_agg(DISTINCT tos."tosID")))
  • Rows Removed by Filter: 8048
35. 32.582 41.468 ↓ 0.0 0 2,962

Bitmap Heap Scan on "TabReceitaParcela" trp_3 (cost=4.52..42.97 rows=1 width=8) (actual time=0.012..0.014 rows=0 loops=2,962)

  • Recheck Cond: ("trptrecID" = trec_3."trecID")
  • Filter: (("trpSubstituida" IS FALSE) AND ("trpBaixada" IS FALSE) AND (NOT "trpIsExcluido") AND (date_part('month'::text, ("trpDataVencimento")::timestamp without time zone) = '1'::double precision) AND (date_part('year'::text, ("trpDataVencimento")::timestamp without time zone) = '2019'::double precision))
  • Rows Removed by Filter: 11
  • Heap Blocks: exact=22340
36. 8.886 8.886 ↓ 1.1 11 2,962

Bitmap Index Scan on idx_trp_trecid_trpsubstituida (cost=0.00..4.52 rows=10 width=0) (actual time=0.003..0.003 rows=11 loops=2,962)

  • Index Cond: (("trptrecID" = trec_3."trecID") AND ("trpSubstituida" = false))
37. 0.029 0.110 ↑ 1.0 35 1

Subquery Scan on *SELECT* 2 (cost=0.00..33.14 rows=36 width=89) (actual time=0.017..0.110 rows=35 loops=1)

38. 0.081 0.081 ↑ 1.0 35 1

Seq Scan on "TabAssessoria" (cost=0.00..32.33 rows=36 width=69) (actual time=0.010..0.081 rows=35 loops=1)

  • Filter: ("tastemID" = 1)
  • Rows Removed by Filter: 72
Planning time : 1.629 ms
Execution time : 585.790 ms