explain.depesz.com

PostgreSQL's explain analyze made readable

Result: myAc

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.035 4,147.702 ↑ 1.0 40 1

Limit (cost=7,875.80..618,067.97 rows=40 width=733) (actual time=177.925..4,147.702 rows=40 loops=1)

2. 0.378 4,147.667 ↑ 4.6 40 1

Result (cost=7,875.80..2,814,759.78 rows=184 width=733) (actual time=177.924..4,147.667 rows=40 loops=1)

3. 0.307 95.169 ↑ 4.6 40 1

Sort (cost=7,875.80..7,876.26 rows=184 width=669) (actual time=95.136..95.169 rows=40 loops=1)

  • Sort Key: (CASE tac."tactuiID" WHEN 3 THEN 1 ELSE 2 END), tac."tacDataFinalizado" NULLS FIRST, twp."twpDue" DESC, twp."twpID
  • Sort Method: top-N heapsort Memory: 47kB
4. 0.702 94.862 ↑ 1.1 161 1

WindowAgg (cost=7,847.90..7,869.98 rows=184 width=669) (actual time=73.613..94.862 rows=161 loops=1)

5. 0.127 73.391 ↑ 1.1 161 1

Group (cost=7,847.90..7,854.80 rows=184 width=469) (actual time=73.254..73.391 rows=161 loops=1)

  • Group Key: tos."tosID", tpc."tpcPrazoValidade", tpc."tpcDescricaoAssessoria", tlsos."tlsosSituacao", tcl."tclID", tpe."tpeTipoPessoa", tpe."tpeNome", tpe."tpeCNPJCPF", tlsos."tlsosDataHora", tde."tdeNome", tse."tseID", tac."tacID", twp."twpDue", twp."twpID
6. 0.537 73.264 ↓ 1.0 185 1

Sort (cost=7,847.90..7,848.36 rows=184 width=469) (actual time=73.251..73.264 rows=185 loops=1)

  • Sort Key: tos."tosID", tpc."tpcPrazoValidade", tpc."tpcDescricaoAssessoria", tlsos."tlsosSituacao", tcl."tclID", tpe."tpeTipoPessoa", tpe."tpeNome", tpe."tpeCNPJCPF", tlsos."tlsosDataHora", tde."tdeNome", tse."tseID", tac."tacID", twp."twpDue" DESC, twp."twpID
  • Sort Method: quicksort Memory: 114kB
7. 0.122 72.727 ↓ 1.0 185 1

Hash Left Join (cost=7,696.39..7,840.98 rows=184 width=469) (actual time=71.708..72.727 rows=185 loops=1)

  • Hash Cond: (tac."tacID" = tacui."tactuitacID")
8. 0.082 47.225 ↑ 1.1 161 1

Nested Loop Left Join (cost=7,686.42..7,828.66 rows=184 width=469) (actual time=46.305..47.225 rows=161 loops=1)

9. 0.075 46.821 ↑ 1.1 161 1

Nested Loop Left Join (cost=7,686.15..7,729.03 rows=184 width=426) (actual time=46.293..46.821 rows=161 loops=1)

10. 0.128 46.424 ↑ 1.1 161 1

Merge Left Join (cost=7,686.00..7,686.94 rows=184 width=418) (actual time=46.270..46.424 rows=161 loops=1)

  • Merge Cond: (tac."tacID" = twp."twptacID")
11. 0.259 1.260 ↑ 1.1 161 1

Sort (cost=68.85..69.31 rows=184 width=406) (actual time=1.232..1.260 rows=161 loops=1)

  • Sort Key: tac."tacID
  • Sort Method: quicksort Memory: 94kB
12. 0.095 1.001 ↑ 1.1 161 1

Hash Left Join (cost=31.57..61.92 rows=184 width=406) (actual time=0.441..1.001 rows=161 loops=1)

  • Hash Cond: (tac."tactclID" = tcl."tclID")
13. 0.088 0.802 ↑ 1.1 161 1

Hash Left Join (cost=24.15..54.01 rows=184 width=398) (actual time=0.326..0.802 rows=161 loops=1)

  • Hash Cond: (tos."tostpcID" = tpc."tpcID")
14. 0.103 0.612 ↑ 1.1 161 1

Hash Left Join (cost=10.85..40.21 rows=184 width=381) (actual time=0.212..0.612 rows=161 loops=1)

  • Hash Cond: (tac."tactosID" = tos."tosID")
15. 0.088 0.385 ↑ 1.1 161 1

Hash Join (cost=2.45..31.32 rows=184 width=351) (actual time=0.078..0.385 rows=161 loops=1)

  • Hash Cond: (tac."tactdeID" = tde."tdeID")
16. 0.090 0.277 ↑ 1.1 161 1

Hash Left Join (cost=1.25..29.41 rows=184 width=319) (actual time=0.038..0.277 rows=161 loops=1)

  • Hash Cond: (tac."tactseID" = tse."tseID")
17. 0.171 0.171 ↑ 1.1 161 1

Seq Scan on "TabAssessoriaCliente" tac (cost=0.00..27.60 rows=184 width=287) (actual time=0.011..0.171 rows=161 loops=1)

  • Filter: (("tacDataFinalizado" IS NULL) AND ("tacDataFinalizado" IS NULL) AND ("tacEstado" = 1) AND ((("tacDataIniciado" >= '2010-01-01 00:00:00-03'::timestamp with time zone) AND ("tacDataIniciado" <= '2020-12-31 23:59:59-03'::timestamp with time zone)) OR ("tacDataIniciado" IS NULL)))
  • Rows Removed by Filter: 164
18. 0.006 0.016 ↓ 1.2 13 1

Hash (cost=1.11..1.11 rows=11 width=36) (actual time=0.015..0.016 rows=13 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
19. 0.010 0.010 ↓ 1.2 13 1

Seq Scan on "TabServico" tse (cost=0.00..1.11 rows=11 width=36) (actual time=0.008..0.010 rows=13 loops=1)

20. 0.010 0.020 ↑ 1.0 9 1

Hash (cost=1.09..1.09 rows=9 width=36) (actual time=0.020..0.020 rows=9 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
21. 0.010 0.010 ↑ 1.0 9 1

Seq Scan on "TabDepartamento" tde (cost=0.00..1.09 rows=9 width=36) (actual time=0.009..0.010 rows=9 loops=1)

22. 0.059 0.124 ↓ 1.0 248 1

Hash (cost=5.40..5.40 rows=240 width=34) (actual time=0.124..0.124 rows=248 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 25kB
23. 0.065 0.065 ↓ 1.0 248 1

Seq Scan on "TabOrdemServico" tos (cost=0.00..5.40 rows=240 width=34) (actual time=0.006..0.065 rows=248 loops=1)

24. 0.049 0.102 ↑ 1.1 248 1

Hash (cost=9.80..9.80 rows=280 width=21) (actual time=0.102..0.102 rows=248 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 22kB
25. 0.053 0.053 ↑ 1.1 248 1

Seq Scan on "TabPropostaComercial" tpc (cost=0.00..9.80 rows=280 width=21) (actual time=0.005..0.053 rows=248 loops=1)

26. 0.048 0.104 ↓ 1.0 251 1

Hash (cost=4.41..4.41 rows=241 width=12) (actual time=0.104..0.104 rows=251 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 19kB
27. 0.056 0.056 ↓ 1.0 251 1

Seq Scan on "TabCliente" tcl (cost=0.00..4.41 rows=241 width=12) (actual time=0.009..0.056 rows=251 loops=1)

28. 0.029 45.036 ↓ 16.0 16 1

Sort (cost=7,617.16..7,617.16 rows=1 width=16) (actual time=45.032..45.036 rows=16 loops=1)

  • Sort Key: twp."twptacID
  • Sort Method: quicksort Memory: 25kB
29. 0.010 45.007 ↓ 16.0 16 1

Subquery Scan on twp (cost=7,616.71..7,617.15 rows=1 width=16) (actual time=44.998..45.007 rows=16 loops=1)

  • Filter: (twp.r = 1)
  • Rows Removed by Filter: 26
30. 0.044 44.997 ↓ 1.4 42 1

Sort (cost=7,616.71..7,616.79 rows=29 width=94) (actual time=44.995..44.997 rows=42 loops=1)

  • Sort Key: "TabWorkingPoint"."twpID" DESC
  • Sort Method: quicksort Memory: 28kB
31. 0.045 44.953 ↓ 1.4 42 1

WindowAgg (cost=7,615.43..7,616.01 rows=29 width=94) (actual time=44.926..44.953 rows=42 loops=1)

32. 0.057 44.908 ↓ 1.4 42 1

Sort (cost=7,615.43..7,615.50 rows=29 width=16) (actual time=44.905..44.908 rows=42 loops=1)

  • Sort Key: "TabWorkingPoint"."twptacID", "TabWorkingPoint"."twpID" DESC
  • Sort Method: quicksort Memory: 26kB
33. 44.851 44.851 ↓ 1.4 42 1

Seq Scan on "TabWorkingPoint" (cost=0.00..7,614.73 rows=29 width=16) (actual time=42.329..44.851 rows=42 loops=1)

  • Filter: (("twpManualFix" IS FALSE) AND ("twpIsDeleted" IS FALSE) AND ("twptuiID" = 3))
  • Rows Removed by Filter: 281
34. 0.322 0.322 ↑ 1.0 1 161

Index Scan using "TabLogSituacaoOrdemServico_tlsosID" on "TabLogSituacaoOrdemServico" tlsos (cost=0.14..0.23 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=161)

  • Index Cond: ("tlsosID" = tos."tostlsosUltimoID")
35. 0.322 0.322 ↑ 1.0 1 161

Index Scan using "TabPessoaID" on "TabPessoa" tpe (cost=0.28..0.54 rows=1 width=51) (actual time=0.002..0.002 rows=1 loops=161)

  • Index Cond: ("tpeID" = tcl."tcltpeID")
36. 0.108 25.380 ↑ 1.0 354 1

Hash (cost=5.54..5.54 rows=354 width=4) (actual time=25.380..25.380 rows=354 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 21kB
37. 25.272 25.272 ↑ 1.0 354 1

Seq Scan on "TabAssessoriaClienteUsuarioInterno" tacui (cost=0.00..5.54 rows=354 width=4) (actual time=0.014..25.272 rows=354 loops=1)

38.          

SubPlan (for WindowAgg)

39. 0.161 0.161 ↑ 1.0 1 161

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=161)

40. 0.161 0.161 ↑ 1.0 1 161

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=161)

41. 20.286 20.286 ↑ 1.0 1 161

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.126..0.126 rows=1 loops=161)

42. 0.161 0.161 ↑ 1.0 1 161

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=161)

43. 0.000 0.000 ↑ 1.0 1 161

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=161)

44.          

SubPlan (for Result)

45. 1.930 4,051.560 ↑ 1.0 1 40

Aggregate (cost=15,242.15..15,242.16 rows=1 width=32) (actual time=101.288..101.289 rows=1 loops=40)

46. 0.104 1,916.240 ↑ 1.0 1 40

Nested Loop Left Join (cost=7,621.69..7,626.65 rows=1 width=65) (actual time=47.894..47.906 rows=1 loops=40)

  • Join Filter: (twp2."twptuiID" = tui."tuiID")
  • Rows Removed by Join Filter: 0
47. 0.288 35.880 ↑ 1.0 1 40

Nested Loop Left Join (cost=6.85..11.76 rows=1 width=53) (actual time=0.886..0.897 rows=1 loops=40)

48. 0.800 34.920 ↑ 1.0 1 40

Hash Join (cost=6.44..9.41 rows=1 width=30) (actual time=0.866..0.873 rows=1 loops=40)

  • Hash Cond: (tui."tuiID" = tacui_1."tactuituiID")
49. 0.320 0.320 ↑ 2.0 35 40

Seq Scan on "TabUsuarioInterno" tui (cost=0.00..2.70 rows=70 width=26) (actual time=0.003..0.008 rows=35 loops=40)

50. 0.200 33.800 ↑ 1.0 1 40

Hash (cost=6.42..6.42 rows=1 width=8) (actual time=0.845..0.845 rows=1 loops=40)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
51. 33.600 33.600 ↑ 1.0 1 40

Seq Scan on "TabAssessoriaClienteUsuarioInterno" tacui_1 (cost=0.00..6.42 rows=1 width=8) (actual time=0.827..0.840 rows=1 loops=40)

  • Filter: ("tactuitacID" = tac."tacID")
  • Rows Removed by Filter: 353
52. 0.168 0.672 ↑ 1.0 1 42

Nested Loop Left Join (cost=0.42..2.34 rows=1 width=31) (actual time=0.013..0.016 rows=1 loops=42)

53. 0.336 0.336 ↑ 1.0 1 42

Index Scan using "TabFuncionario_tfuID" on "TabFuncionario" tfu (cost=0.14..0.33 rows=1 width=8) (actual time=0.006..0.008 rows=1 loops=42)

  • Index Cond: ("tfuID" = tui."tuitfuID")
54. 0.168 0.168 ↑ 1.0 1 42

Index Scan using "TabPessoaID" on "TabPessoa" tpe_resposavel (cost=0.28..2.01 rows=1 width=31) (actual time=0.004..0.004 rows=1 loops=42)

  • Index Cond: ("tpeID" = tfu."tfutpeID")
55. 0.126 1,880.256 ↓ 0.0 0 42

Subquery Scan on twp2 (cost=7,614.83..7,614.88 rows=1 width=16) (actual time=44.767..44.768 rows=0 loops=42)

  • Filter: (twp2.r = 1)
  • Rows Removed by Filter: 0
56. 0.250 1,880.130 ↑ 3.0 1 42

Sort (cost=7,614.83..7,614.84 rows=3 width=94) (actual time=44.765..44.765 rows=1 loops=42)

  • Sort Key: twp2_1."twpID" DESC
  • Sort Method: quicksort Memory: 25kB
57. 0.200 1,879.880 ↑ 3.0 1 40

WindowAgg (cost=7,614.75..7,614.81 rows=3 width=94) (actual time=46.996..46.997 rows=1 loops=40)

58. 0.360 1,879.680 ↑ 3.0 1 40

Sort (cost=7,614.75..7,614.76 rows=3 width=16) (actual time=46.992..46.992 rows=1 loops=40)

  • Sort Key: twp2_1."twptuiID", twp2_1."twpID" DESC
  • Sort Method: quicksort Memory: 25kB
59. 1,879.320 1,879.320 ↑ 3.0 1 40

Seq Scan on "TabWorkingPoint" twp2_1 (cost=0.00..7,614.73 rows=3 width=16) (actual time=45.222..46.983 rows=1 loops=40)

  • Filter: (("twpManualFix" IS FALSE) AND ("twpIsDeleted" IS FALSE) AND ("twptacID" = tac."tacID"))
  • Rows Removed by Filter: 322
60.          

SubPlan (for Aggregate)

61. 0.420 2,133.390 ↑ 1.0 1 42

Aggregate (cost=7,615.48..7,615.49 rows=1 width=8) (actual time=50.795..50.795 rows=1 loops=42)

62. 2,132.970 2,132.970 ↑ 1.0 1 42

Seq Scan on "TabWorkingPoint" twp3 (cost=0.00..7,615.47 rows=1 width=8) (actual time=47.069..50.785 rows=1 loops=42)

  • Filter: (("twpIsDeleted" IS FALSE) AND ("twptacID" = tac."tacID") AND ("twptuiID" = tui."tuiID"))
  • Rows Removed by Filter: 322
63. 0.280 0.560 ↑ 1.0 1 40

Aggregate (cost=12.55..12.56 rows=1 width=32) (actual time=0.014..0.014 rows=1 loops=40)

64. 0.000 0.280 ↓ 0.0 0 40

Nested Loop (cost=0.00..2.30 rows=1 width=19) (actual time=0.007..0.007 rows=0 loops=40)

  • Join Filter: (tltac."tltactlID" = tl."tlID")
65. 0.280 0.280 ↓ 0.0 0 40

Seq Scan on "TabLabels" tl (cost=0.00..1.16 rows=1 width=15) (actual time=0.007..0.007 rows=0 loops=40)

  • Filter: ("tlISDeleted" IS FALSE)
  • Rows Removed by Filter: 16
66. 0.000 0.000 ↓ 0.0 0

Seq Scan on "TabLabelsAssessoriaCliente" tltac (cost=0.00..1.10 rows=3 width=8) (never executed)

  • Filter: (tac."tacID" = "tltactacID")
67.          

SubPlan (for Aggregate)

68. 0.000 0.000 ↓ 0.0 0

Function Scan on proc_component_getlabelscolor (cost=0.25..10.25 rows=1,000 width=32) (never executed)

Planning time : 54.740 ms
Execution time : 4,176.811 ms