explain.depesz.com

PostgreSQL's explain analyze made readable

Result: pR5L : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: plan #3HiS; plan #ZCGu; plan #GKJL; plan #Y6VX; plan #9lxI; plan #hlYt

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.070 8,697.077 ↓ 13.3 40 1

Limit (cost=16,018.18..16,018.28 rows=3 width=59) (actual time=8,696.994..8,697.077 rows=40 loops=1)

2. 0.525 8,697.007 ↓ 13.3 40 1

WindowAgg (cost=16,018.18..16,018.28 rows=3 width=59) (actual time=8,696.992..8,697.007 rows=40 loops=1)

3. 1.042 8,696.482 ↓ 339.7 1,019 1

Group (cost=16,018.18..16,018.24 rows=3 width=51) (actual time=8,694.973..8,696.482 rows=1,019 loops=1)

  • Group Key: tpe."tpeNome", tcl."tclID", tpe."tpeCNPJCPF", tpe."tpeTipoPessoa", tsc."tscMes", tsc."tscAno", tos."tosAtendimentoSuspenso
4. 5.199 8,695.440 ↓ 677.3 2,032 1

Sort (cost=16,018.18..16,018.19 rows=3 width=51) (actual time=8,694.970..8,695.440 rows=2,032 loops=1)

  • Sort Key: tpe."tpeNome", tcl."tclID", tpe."tpeCNPJCPF", tpe."tpeTipoPessoa", tsc."tscMes", tsc."tscAno", tos."tosAtendimentoSuspenso
  • Sort Method: quicksort Memory: 335kB
5. 0.749 8,690.241 ↓ 677.3 2,032 1

Append (cost=8,199.20..16,018.16 rows=3 width=51) (actual time=4,346.854..8,690.241 rows=2,032 loops=1)

6. 0.623 4,347.819 ↓ 1,015.0 1,015 1

Unique (cost=8,199.20..8,199.22 rows=1 width=51) (actual time=4,346.853..4,347.819 rows=1,015 loops=1)

7. 1.683 4,347.196 ↓ 1,048.0 1,048 1

Sort (cost=8,199.20..8,199.20 rows=1 width=51) (actual time=4,346.852..4,347.196 rows=1,048 loops=1)

  • Sort Key: tcl."tclID", tpe."tpeNome", tpe."tpeCNPJCPF", tpe."tpeTipoPessoa", tos."tosAtendimentoSuspenso
  • Sort Method: quicksort Memory: 196kB
8. 456.102 4,345.513 ↓ 1,048.0 1,048 1

Nested Loop (cost=5,234.19..8,199.19 rows=1 width=51) (actual time=186.630..4,345.513 rows=1,048 loops=1)

  • Join Filter: (tos."tostclID" = thrfc."thrfctclID")
  • Rows Removed by Join Filter: 2088907
9. 1.447 207.461 ↓ 1,055.0 1,055 1

Nested Loop (cost=5,058.63..7,945.14 rows=1 width=55) (actual time=181.489..207.461 rows=1,055 loops=1)

10. 42.101 182.804 ↓ 1,055.0 1,055 1

Hash Right Join (cost=5,058.35..7,942.17 rows=1 width=21) (actual time=181.389..182.804 rows=1,055 loops=1)

  • Hash Cond: (tsl2."tsltscID" = tsc."tscID")
  • Join Filter: ((tsl."tslDataHora" < tsl2."tslDataHora") OR ((tsl."tslDataHora" = tsl2."tslDataHora") AND (tsl."tsltscID" < tsl2."tsltscID")))
  • Rows Removed by Join Filter: 17891
  • Filter: (tsl2."tslID" IS NULL)
  • Rows Removed by Filter: 12587
11. 31.475 31.475 ↑ 1.0 136,578 1

Seq Scan on "TabSICILogAlteracaoSituacao" tsl2 (cost=0.00..2,371.00 rows=136,600 width=16) (actual time=0.011..31.475 rows=136,578 loops=1)

12. 5.861 109.228 ↓ 884.0 5,304 1

Hash (cost=5,058.27..5,058.27 rows=6 width=37) (actual time=109.228..109.228 rows=5,304 loops=1)

  • Buckets: 8192 (originally 1024) Batches: 1 (originally 1) Memory Usage: 437kB
13. 39.619 103.367 ↓ 884.0 5,304 1

Hash Join (cost=2,174.96..5,058.27 rows=6 width=37) (actual time=31.208..103.367 rows=5,304 loops=1)

  • Hash Cond: (tsl."tsltscID" = tsc."tscID")
14. 33.101 33.101 ↑ 1.0 136,578 1

Seq Scan on "TabSICILogAlteracaoSituacao" tsl (cost=0.00..2,371.00 rows=136,600 width=12) (actual time=0.013..33.101 rows=136,578 loops=1)

15. 0.502 30.647 ↓ 1,055.0 1,055 1

Hash (cost=2,174.95..2,174.95 rows=1 width=25) (actual time=30.646..30.647 rows=1,055 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 78kB
16. 1.442 30.145 ↓ 1,055.0 1,055 1

Nested Loop Anti Join (cost=1.56..2,174.95 rows=1 width=25) (actual time=4.718..30.145 rows=1,055 loops=1)

17. 1.516 26.593 ↓ 1,055.0 1,055 1

Nested Loop (cost=1.27..2,172.44 rows=1 width=41) (actual time=4.708..26.593 rows=1,055 loops=1)

  • Join Filter: (tos."tosID" = tlsos."tlsostosID")
18. 0.945 20.989 ↓ 1,022.0 1,022 1

Nested Loop (cost=0.98..2,169.52 rows=1 width=33) (actual time=4.695..20.989 rows=1,022 loops=1)

19. 0.758 18.000 ↓ 1,022.0 1,022 1

Nested Loop (cost=0.70..2,167.36 rows=1 width=25) (actual time=4.688..18.000 rows=1,022 loops=1)

20. 2.686 14.176 ↓ 1,022.0 1,022 1

Nested Loop (cost=0.42..2,164.94 rows=1 width=16) (actual time=4.680..14.176 rows=1,022 loops=1)

  • Join Filter: (tac."tactseID" = tse."tseID")
  • Rows Removed by Join Filter: 6132
21. 1.139 8.424 ↓ 5.8 1,022 1

Nested Loop (cost=0.42..2,126.39 rows=175 width=20) (actual time=3.595..8.424 rows=1,022 loops=1)

22. 4.219 4.219 ↓ 5.8 1,022 1

Seq Scan on "TabSICIColetaMensal" tsc (cost=0.00..652.08 rows=175 width=16) (actual time=3.583..4.219 rows=1,022 loops=1)

  • Filter: (("tscIsExcluido" IS FALSE) AND ("tscMes" = 3) AND ("tscAno" = 2019))
  • Rows Removed by Filter: 23563
23. 3.066 3.066 ↑ 1.0 1 1,022

Index Scan using "TabAssessoriaCliente_tacID" on "TabAssessoriaCliente" tac (cost=0.42..8.41 rows=1 width=12) (actual time=0.003..0.003 rows=1 loops=1,022)

  • Index Cond: ("tacID" = tsc."tsctacID")
24. 1.466 3.066 ↓ 1.8 7 1,022

Materialize (cost=0.00..28.06 rows=4 width=4) (actual time=0.001..0.003 rows=7 loops=1,022)

25. 1.600 1.600 ↓ 1.8 7 1

Seq Scan on "TabServico" tse (cost=0.00..28.04 rows=4 width=4) (actual time=1.073..1.600 rows=7 loops=1)

  • Filter: ("tseSistemaAgregado" = 1)
  • Rows Removed by Filter: 810
26. 3.066 3.066 ↑ 1.0 1 1,022

Index Scan using "TabOrdemServico_tosID" on "TabOrdemServico" tos (cost=0.28..2.41 rows=1 width=9) (actual time=0.002..0.003 rows=1 loops=1,022)

  • Index Cond: ("tosID" = tac."tactosID")
27. 2.044 2.044 ↑ 1.0 1 1,022

Index Scan using "TabCliente_tclID" on "TabCliente" tcl (cost=0.28..2.15 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,022)

  • Index Cond: ("tclID" = tos."tostclID")
28. 4.088 4.088 ↑ 1.0 1 1,022

Index Scan using idx_tlsos_tosid on "TabLogSituacaoOrdemServico" tlsos (cost=0.29..2.91 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=1,022)

  • Index Cond: ("tlsostosID" = tac."tactosID")
  • Filter: ("tlsosSituacao" = ANY ('{3,7,9}'::integer[]))
  • Rows Removed by Filter: 3
29. 2.110 2.110 ↓ 0.0 0 1,055

Index Scan using "TabLogSituacaoOrdemServico_tlsosID" on "TabLogSituacaoOrdemServico" tlsos2 (cost=0.29..2.49 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=1,055)

  • Index Cond: ("tlsosID" = tlsos."tlsosID")
  • Filter: ((tlsos."tlsosDataHora" < "tlsosDataHora") OR ((tlsos."tlsosDataHora" = "tlsosDataHora") AND (tlsos."tlsostosID" < "tlsostosID")))
  • Rows Removed by Filter: 1
30. 23.210 23.210 ↑ 1.0 1 1,055

Index Scan using "TabPessoaID" on "TabPessoa" tpe (cost=0.29..2.96 rows=1 width=42) (actual time=0.021..0.022 rows=1 loops=1,055)

  • Index Cond: ("tpeID" = tcl."tcltpeID")
  • Filter: ((COALESCE("tpeCNPJCPF", ''::text) ~~* '%%'::text) AND (proc_common_remove_acento("tpeNome") ~~* '%%'::text))
31. 1,024.405 3,681.950 ↓ 180.1 1,981 1,055

Subquery Scan on thrfc (cost=175.55..253.91 rows=11 width=4) (actual time=0.004..3.490 rows=1,981 loops=1,055)

  • Filter: ((thrfc."thrfcIs_Excluido" IS FALSE) AND (thrfc.r = 1))
  • Rows Removed by Filter: 462
32. 2,042.480 2,657.545 ↓ 1.0 2,443 1,055

WindowAgg (cost=175.55..223.77 rows=2,411 width=33) (actual time=0.003..2.519 rows=2,443 loops=1,055)

33. 614.339 615.065 ↓ 1.0 2,443 1,055

Sort (cost=175.55..181.58 rows=2,411 width=9) (actual time=0.002..0.583 rows=2,443 loops=1,055)

  • Sort Key: "TabHistoricoRegimeFiscalCliente"."thrfctclID", "TabHistoricoRegimeFiscalCliente"."thrfcID" DESC
  • Sort Method: quicksort Memory: 211kB
34. 0.726 0.726 ↓ 1.0 2,443 1

Seq Scan on "TabHistoricoRegimeFiscalCliente" (cost=0.00..40.11 rows=2,411 width=9) (actual time=0.012..0.726 rows=2,443 loops=1)

35. 0.583 4,324.019 ↓ 1,016.0 1,016 1

Unique (cost=7,511.76..7,511.77 rows=1 width=51) (actual time=4,323.076..4,324.019 rows=1,016 loops=1)

36. 1.818 4,323.436 ↓ 1,049.0 1,049 1

Sort (cost=7,511.76..7,511.76 rows=1 width=51) (actual time=4,323.076..4,323.436 rows=1,049 loops=1)

  • Sort Key: tcl_1."tclID", tpe_1."tpeNome", tpe_1."tpeCNPJCPF", tpe_1."tpeTipoPessoa", tos_1."tosAtendimentoSuspenso
  • Sort Method: quicksort Memory: 196kB
37. 469.028 4,321.618 ↓ 1,049.0 1,049 1

Nested Loop (cost=5,622.32..7,511.75 rows=1 width=51) (actual time=121.695..4,321.618 rows=1,049 loops=1)

  • Join Filter: (tos_1."tostclID" = thrfc_1."thrfctclID")
  • Rows Removed by Join Filter: 2090887
38. 1.756 141.806 ↓ 1,056.0 1,056 1

Nested Loop (cost=5,446.77..7,257.70 rows=1 width=55) (actual time=116.977..141.806 rows=1,056 loops=1)

39. 25.783 117.874 ↓ 1,056.0 1,056 1

Hash Right Join (cost=5,446.48..7,254.76 rows=1 width=21) (actual time=116.883..117.874 rows=1,056 loops=1)

  • Hash Cond: (tfls2."tflstfcmID" = tfcm."tfcmID")
  • Join Filter: ((tfls."tflsDataHora" < tfls2."tflsDataHora") OR ((tfls."tflsDataHora" = tfls2."tflsDataHora") AND (tfls."tflstfcmID" < tfls2."tflstfcmID")))
  • Rows Removed by Join Filter: 3521
  • Filter: (tfls2."tflsID" IS NULL)
  • Rows Removed by Filter: 1487
40. 20.757 20.757 ↑ 1.0 85,576 1

Seq Scan on "TabFUSTLogSituacao" tfls2 (cost=0.00..1,486.80 rows=85,680 width=16) (actual time=0.011..20.757 rows=85,576 loops=1)

41. 0.848 71.334 ↓ 678.0 2,034 1

Hash (cost=5,446.44..5,446.44 rows=3 width=37) (actual time=71.334..71.334 rows=2,034 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 160kB
42. 22.752 70.486 ↓ 678.0 2,034 1

Hash Join (cost=3,638.31..5,446.44 rows=3 width=37) (actual time=27.813..70.486 rows=2,034 loops=1)

  • Hash Cond: (tfls."tflstfcmID" = tfcm."tfcmID")
43. 20.151 20.151 ↑ 1.0 85,576 1

Seq Scan on "TabFUSTLogSituacao" tfls (cost=0.00..1,486.80 rows=85,680 width=12) (actual time=0.020..20.151 rows=85,576 loops=1)

44. 0.519 27.583 ↓ 1,056.0 1,056 1

Hash (cost=3,638.30..3,638.30 rows=1 width=25) (actual time=27.582..27.583 rows=1,056 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 78kB
45. 0.990 27.064 ↓ 1,056.0 1,056 1

Nested Loop (cost=1.56..3,638.30 rows=1 width=25) (actual time=0.304..27.064 rows=1,056 loops=1)

46. 1.191 23.962 ↓ 1,056.0 1,056 1

Nested Loop (cost=1.28..3,636.14 rows=1 width=17) (actual time=0.295..23.962 rows=1,056 loops=1)

  • Join Filter: (tlsos_1."tlsostosID" = tos_1."tosID")
47. 0.924 20.659 ↓ 1,056.0 1,056 1

Nested Loop Anti Join (cost=0.99..3,633.75 rows=1 width=20) (actual time=0.283..20.659 rows=1,056 loops=1)

48. 1.460 17.623 ↓ 528.0 1,056 1

Nested Loop (cost=0.71..3,628.79 rows=2 width=32) (actual time=0.270..17.623 rows=1,056 loops=1)

49. 2.919 13.094 ↓ 511.5 1,023 1

Nested Loop (cost=0.42..3,623.01 rows=2 width=16) (actual time=0.255..13.094 rows=1,023 loops=1)

  • Join Filter: (tac_1."tactseID" = tse_1."tseID")
  • Rows Removed by Join Filter: 10230
50. 0.907 7.106 ↓ 2.9 1,023 1

Nested Loop (cost=0.42..3,573.84 rows=352 width=20) (actual time=0.108..7.106 rows=1,023 loops=1)

51. 3.130 3.130 ↓ 2.9 1,023 1

Seq Scan on "TabFUSTColetaMensal" tfcm (cost=0.00..616.32 rows=352 width=16) (actual time=0.081..3.130 rows=1,023 loops=1)

  • Filter: (("tfcmMes" = 3) AND ("tfcmAno" = 2019))
  • Rows Removed by Filter: 23571
52. 3.069 3.069 ↑ 1.0 1 1,023

Index Scan using "TabAssessoriaCliente_tacID" on "TabAssessoriaCliente" tac_1 (cost=0.42..8.39 rows=1 width=12) (actual time=0.003..0.003 rows=1 loops=1,023)

  • Index Cond: ("tacID" = tfcm."tfcmtacID")
53. 2.896 3.069 ↓ 2.8 11 1,023

Materialize (cost=0.00..28.06 rows=4 width=4) (actual time=0.000..0.003 rows=11 loops=1,023)

54. 0.173 0.173 ↓ 2.8 11 1

Seq Scan on "TabServico" tse_1 (cost=0.00..28.04 rows=4 width=4) (actual time=0.129..0.173 rows=11 loops=1)

  • Filter: ("tseSistemaAgregado" = 2)
  • Rows Removed by Filter: 806
55. 3.069 3.069 ↑ 1.0 1 1,023

Index Scan using idx_tlsos_tosid on "TabLogSituacaoOrdemServico" tlsos_1 (cost=0.29..2.88 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=1,023)

  • Index Cond: ("tlsostosID" = tac_1."tactosID")
  • Filter: ("tlsosSituacao" = ANY ('{3,7,9}'::integer[]))
  • Rows Removed by Filter: 3
56. 2.112 2.112 ↓ 0.0 0 1,056

Index Scan using "TabLogSituacaoOrdemServico_tlsosID" on "TabLogSituacaoOrdemServico" tlsos2_1 (cost=0.29..2.47 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=1,056)

  • Index Cond: ("tlsosID" = tlsos_1."tlsosID")
  • Filter: ((tlsos_1."tlsosDataHora" < "tlsosDataHora") OR ((tlsos_1."tlsosDataHora" = "tlsosDataHora") AND (tlsos_1."tlsostosID" < "tlsostosID")))
  • Rows Removed by Filter: 1
57. 2.112 2.112 ↑ 1.0 1 1,056

Index Scan using "TabOrdemServico_tosID" on "TabOrdemServico" tos_1 (cost=0.28..2.38 rows=1 width=9) (actual time=0.002..0.002 rows=1 loops=1,056)

  • Index Cond: ("tosID" = tac_1."tactosID")
58. 2.112 2.112 ↑ 1.0 1 1,056

Index Scan using "TabCliente_tclID" on "TabCliente" tcl_1 (cost=0.28..2.15 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,056)

  • Index Cond: ("tclID" = tos_1."tostclID")
59. 22.176 22.176 ↑ 1.0 1 1,056

Index Scan using "TabPessoaID" on "TabPessoa" tpe_1 (cost=0.29..2.93 rows=1 width=42) (actual time=0.020..0.021 rows=1 loops=1,056)

  • Index Cond: ("tpeID" = tcl_1."tcltpeID")
  • Filter: ((COALESCE("tpeCNPJCPF", ''::text) ~~* '%%'::text) AND (proc_common_remove_acento("tpeNome") ~~* '%%'::text))
60. 1,045.440 3,710.784 ↓ 180.1 1,981 1,056

Subquery Scan on thrfc_1 (cost=175.55..253.91 rows=11 width=4) (actual time=0.004..3.514 rows=1,981 loops=1,056)

  • Filter: ((thrfc_1."thrfcIs_Excluido" IS FALSE) AND (thrfc_1.r = 1))
  • Rows Removed by Filter: 462
61. 2,041.248 2,665.344 ↓ 1.0 2,443 1,056

WindowAgg (cost=175.55..223.77 rows=2,411 width=33) (actual time=0.003..2.524 rows=2,443 loops=1,056)

62. 623.414 624.096 ↓ 1.0 2,443 1,056

Sort (cost=175.55..181.58 rows=2,411 width=9) (actual time=0.002..0.591 rows=2,443 loops=1,056)

  • Sort Key: "TabHistoricoRegimeFiscalCliente_1"."thrfctclID", "TabHistoricoRegimeFiscalCliente_1"."thrfcID" DESC
  • Sort Method: quicksort Memory: 211kB
63. 0.682 0.682 ↓ 1.0 2,443 1

Seq Scan on "TabHistoricoRegimeFiscalCliente" "TabHistoricoRegimeFiscalCliente_1" (cost=0.00..40.11 rows=2,411 width=9) (actual time=0.014..0.682 rows=2,443 loops=1)

64. 0.001 17.654 ↑ 1.0 1 1

Unique (cost=307.12..307.14 rows=1 width=51) (actual time=17.652..17.654 rows=1 loops=1)

65. 0.024 17.653 ↓ 3.0 3 1

Sort (cost=307.12..307.13 rows=1 width=51) (actual time=17.651..17.653 rows=3 loops=1)

  • Sort Key: tcl_2."tclID", tpe_2."tpeNome", tpe_2."tpeCNPJCPF", tpe_2."tpeTipoPessoa", tos_2."tosAtendimentoSuspenso
  • Sort Method: quicksort Memory: 25kB
66. 1.319 17.629 ↓ 3.0 3 1

Nested Loop (cost=212.14..307.11 rows=1 width=51) (actual time=8.352..17.629 rows=3 loops=1)

  • Join Filter: (tos_2."tostclID" = thrfc_2."thrfctclID")
  • Rows Removed by Join Filter: 5940
67. 0.009 3.956 ↓ 3.0 3 1

Nested Loop (cost=36.59..53.06 rows=1 width=55) (actual time=3.422..3.956 rows=3 loops=1)

68. 0.074 3.869 ↓ 3.0 3 1

Nested Loop (cost=36.30..50.24 rows=1 width=21) (actual time=3.383..3.869 rows=3 loops=1)

  • Join Filter: (tsgql."tsgqltsgqcmID" = tsgqll."tsgqltsgqcmID")
  • Rows Removed by Join Filter: 132
69. 0.068 0.330 ↓ 45.0 45 1

Subquery Scan on tsgqll (cost=14.80..23.12 rows=1 width=4) (actual time=0.139..0.330 rows=45 loops=1)

  • Filter: (tsgqll.s = 1)
  • Rows Removed by Filter: 106
70. 0.092 0.262 ↑ 1.7 151 1

WindowAgg (cost=14.80..19.92 rows=256 width=36) (actual time=0.130..0.262 rows=151 loops=1)

71. 0.111 0.170 ↑ 1.7 151 1

Sort (cost=14.80..15.44 rows=256 width=8) (actual time=0.127..0.170 rows=151 loops=1)

  • Sort Key: "TabSGQLogSituacao"."tsgqltsgqcmID", "TabSGQLogSituacao"."tsgqlID" DESC
  • Sort Method: quicksort Memory: 32kB
72. 0.059 0.059 ↑ 1.7 151 1

Seq Scan on "TabSGQLogSituacao" (cost=0.00..4.56 rows=256 width=8) (actual time=0.013..0.059 rows=151 loops=1)

73. 1.871 3.465 ↑ 2.0 3 45

Hash Join (cost=21.50..27.05 rows=6 width=29) (actual time=0.063..0.077 rows=3 loops=45)

  • Hash Cond: (tsgql."tsgqltsgqcmID" = tsgqcm."tsgqcmID")
74. 1.485 1.485 ↑ 1.7 151 45

Seq Scan on "TabSGQLogSituacao" tsgql (cost=0.00..4.56 rows=256 width=4) (actual time=0.002..0.033 rows=151 loops=45)

75. 0.004 0.109 ↑ 1.0 1 1

Hash (cost=21.49..21.49 rows=1 width=25) (actual time=0.109..0.109 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
76. 0.003 0.105 ↑ 1.0 1 1

Nested Loop (cost=1.83..21.49 rows=1 width=25) (actual time=0.096..0.105 rows=1 loops=1)

77. 0.003 0.091 ↑ 1.0 1 1

Nested Loop Anti Join (cost=1.56..19.49 rows=1 width=29) (actual time=0.084..0.091 rows=1 loops=1)

78. 0.006 0.077 ↑ 1.0 1 1

Nested Loop (cost=1.27..17.16 rows=1 width=45) (actual time=0.070..0.077 rows=1 loops=1)

  • Join Filter: (tos_2."tosID" = tlsos_2."tlsostosID")
79. 0.003 0.053 ↑ 1.0 1 1

Nested Loop (cost=0.98..14.44 rows=1 width=37) (actual time=0.048..0.053 rows=1 loops=1)

80. 0.005 0.043 ↑ 1.0 1 1

Nested Loop (cost=0.70..12.43 rows=1 width=29) (actual time=0.040..0.043 rows=1 loops=1)

81. 0.002 0.031 ↑ 1.0 1 1

Nested Loop (cost=0.42..10.11 rows=1 width=20) (actual time=0.029..0.031 rows=1 loops=1)

82. 0.018 0.018 ↑ 1.0 1 1

Seq Scan on "TabSGQColetaMensal" tsgqcm (cost=0.00..1.66 rows=1 width=16) (actual time=0.015..0.018 rows=1 loops=1)

  • Filter: (("tsgqcmMes" = 3) AND ("tsgqcmAno" = 2019))
  • Rows Removed by Filter: 44
83. 0.011 0.011 ↑ 1.0 1 1

Index Scan using "TabAssessoriaCliente_tacID" on "TabAssessoriaCliente" tac_2 (cost=0.42..8.44 rows=1 width=12) (actual time=0.011..0.011 rows=1 loops=1)

  • Index Cond: ("tacID" = tsgqcm."tsgqcmtacID")
84. 0.007 0.007 ↑ 1.0 1 1

Index Scan using "TabOrdemServico_tosID" on "TabOrdemServico" tos_2 (cost=0.28..2.31 rows=1 width=9) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: ("tosID" = tac_2."tactosID")
85. 0.007 0.007 ↑ 1.0 1 1

Index Scan using "TabCliente_tclID" on "TabCliente" tcl_2 (cost=0.28..2.00 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=1)

  • Index Cond: ("tclID" = tos_2."tostclID")
86. 0.018 0.018 ↑ 1.0 1 1

Index Scan using idx_tlsos_tosid on "TabLogSituacaoOrdemServico" tlsos_2 (cost=0.29..2.70 rows=1 width=16) (actual time=0.015..0.018 rows=1 loops=1)

  • Index Cond: ("tlsostosID" = tac_2."tactosID")
  • Filter: ("tlsosSituacao" = ANY ('{3,7,9}'::integer[]))
  • Rows Removed by Filter: 4
87. 0.011 0.011 ↓ 0.0 0 1

Index Scan using "TabLogSituacaoOrdemServico_tlsosID" on "TabLogSituacaoOrdemServico" tlsos2_2 (cost=0.29..2.32 rows=1 width=16) (actual time=0.011..0.011 rows=0 loops=1)

  • Index Cond: ("tlsosID" = tlsos_2."tlsosID")
  • Filter: ((tlsos_2."tlsosDataHora" < "tlsosDataHora") OR ((tlsos_2."tlsosDataHora" = "tlsosDataHora") AND (tlsos_2."tlsostosID" < "tlsostosID")))
  • Rows Removed by Filter: 1
88. 0.011 0.011 ↑ 1.0 1 1

Index Scan using "TabServico_tseID" on "TabServico" tse_2 (cost=0.28..1.98 rows=1 width=4) (actual time=0.010..0.011 rows=1 loops=1)

  • Index Cond: ("tseID" = tac_2."tactseID")
  • Filter: ("tseSistemaAgregado" = 3)
89. 0.078 0.078 ↑ 1.0 1 3

Index Scan using "TabPessoaID" on "TabPessoa" tpe_2 (cost=0.29..2.81 rows=1 width=42) (actual time=0.026..0.026 rows=1 loops=3)

  • Index Cond: ("tpeID" = tcl_2."tcltpeID")
  • Filter: ((COALESCE("tpeCNPJCPF", ''::text) ~~* '%%'::text) AND (proc_common_remove_acento("tpeNome") ~~* '%%'::text))
90. 2.937 12.354 ↓ 180.1 1,981 3

Subquery Scan on thrfc_2 (cost=175.55..253.91 rows=11 width=4) (actual time=0.625..4.118 rows=1,981 loops=3)

  • Filter: ((thrfc_2."thrfcIs_Excluido" IS FALSE) AND (thrfc_2.r = 1))
  • Rows Removed by Filter: 462
91. 5.733 9.417 ↓ 1.0 2,443 3

WindowAgg (cost=175.55..223.77 rows=2,411 width=33) (actual time=0.623..3.139 rows=2,443 loops=3)

92. 3.034 3.684 ↓ 1.0 2,443 3

Sort (cost=175.55..181.58 rows=2,411 width=9) (actual time=0.622..1.228 rows=2,443 loops=3)

  • Sort Key: "TabHistoricoRegimeFiscalCliente_2"."thrfctclID", "TabHistoricoRegimeFiscalCliente_2"."thrfcID" DESC
  • Sort Method: quicksort Memory: 211kB
93. 0.650 0.650 ↓ 1.0 2,443 1

Seq Scan on "TabHistoricoRegimeFiscalCliente" "TabHistoricoRegimeFiscalCliente_2" (cost=0.00..40.11 rows=2,411 width=9) (actual time=0.007..0.650 rows=2,443 loops=1)

Planning time : 11.788 ms
Execution time : 8,697.983 ms