explain.depesz.com

PostgreSQL's explain analyze made readable

Result: aQTH

Settings
# exclusive inclusive rows x rows loops node
1. 2.379 1,188.093 ↓ 40.0 40 1

Subquery Scan on r (cost=2,211.72..7,206.34 rows=1 width=1,098) (actual time=356.894..1,188.093 rows=40 loops=1)

2. 0.109 334.914 ↓ 40.0 40 1

Limit (cost=2,211.72..2,211.77 rows=1 width=807) (actual time=334.574..334.914 rows=40 loops=1)

3. 7.359 334.805 ↓ 9.6 240 1

WindowAgg (cost=2,210.41..2,211.72 rows=25 width=807) (actual time=334.354..334.805 rows=240 loops=1)

4. 7.586 327.446 ↓ 267.2 6,679 1

Group (cost=2,210.41..2,211.41 rows=25 width=758) (actual time=317.623..327.446 rows=6,679 loops=1)

  • Group Key: trp."trpID", tpe."tpeID", tcl."tclID", tos."tosID", tpc."tpcID", tcb."tcbID", tbc."tbcID", tba."tbaID", trec."trecID", ttb."ttbID", trem."tremID", tfu."tfuID", tpe_funcionario."tpeID", tct."tctID", tlsos."tlsosSituacao
5. 12.768 319.860 ↓ 267.2 6,679 1

Sort (cost=2,210.41..2,210.47 rows=25 width=758) (actual time=317.620..319.860 rows=6,679 loops=1)

  • Sort Key: trp."trpID", tpe."tpeID", tcl."tclID", tos."tosID", tpc."tpcID", tcb."tcbID", tbc."tbcID", tba."tbaID", trec."trecID", ttb."ttbID", trem."tremID", tfu."tfuID", tpe_funcionario."tpeID", tct."tctID", tlsos."tlsosSituacao
  • Sort Method: quicksort Memory: 3622kB
6. 4.857 307.092 ↓ 267.2 6,679 1

Hash Left Join (cost=247.81..2,209.83 rows=25 width=758) (actual time=3.650..307.092 rows=6,679 loops=1)

  • Hash Cond: (tcfos."tcfosID" = tct."tcttcfosID")
7. 4.941 301.960 ↓ 267.2 6,679 1

Hash Left Join (cost=221.95..2,183.59 rows=25 width=740) (actual time=3.368..301.960 rows=6,679 loops=1)

  • Hash Cond: (tos."tosID" = tcfos."tcfostosID")
8. 8.330 296.816 ↓ 267.2 6,679 1

Nested Loop Left Join (cost=211.08..2,172.61 rows=25 width=736) (actual time=3.159..296.816 rows=6,679 loops=1)

9. 8.590 288.486 ↓ 267.2 6,679 1

Nested Loop Left Join (cost=210.80..2,164.54 rows=25 width=727) (actual time=3.157..288.486 rows=6,679 loops=1)

10. 13.919 279.896 ↓ 267.2 6,679 1

Nested Loop Left Join (cost=210.67..2,160.37 rows=25 width=695) (actual time=3.155..279.896 rows=6,679 loops=1)

  • Join Filter: (tba."tbaID" = tbc."tbctbaID")
  • Rows Removed by Join Filter: 20494
11. 7.812 259.298 ↓ 267.2 6,679 1

Nested Loop Left Join (cost=210.67..2,157.82 rows=25 width=691) (actual time=3.145..259.298 rows=6,679 loops=1)

  • Join Filter: (tbc."tbcID" = tcb."tcbtbcID")
  • Rows Removed by Join Filter: 7136
12. 7.135 244.807 ↓ 267.2 6,679 1

Nested Loop Left Join (cost=210.67..2,156.05 rows=25 width=655) (actual time=3.135..244.807 rows=6,679 loops=1)

13. 10.708 224.314 ↓ 267.2 6,679 1

Nested Loop (cost=210.53..2,151.94 rows=25 width=475) (actual time=3.126..224.314 rows=6,679 loops=1)

14. 6.881 126.779 ↓ 109.5 6,679 1

Nested Loop (cost=210.25..2,083.28 rows=61 width=437) (actual time=3.087..126.779 rows=6,679 loops=1)

15. 3.814 89.118 ↓ 60.0 3,420 1

Nested Loop (cost=209.96..1,966.83 rows=57 width=143) (actual time=3.035..89.118 rows=3,420 loops=1)

16. 3.327 78.464 ↓ 60.0 3,420 1

Nested Loop Left Join (cost=209.68..1,946.86 rows=57 width=139) (actual time=3.028..78.464 rows=3,420 loops=1)

17. 2.691 68.297 ↓ 60.0 3,420 1

Nested Loop Left Join (cost=209.39..1,719.24 rows=57 width=119) (actual time=3.024..68.297 rows=3,420 loops=1)

18. 5.128 58.766 ↓ 60.0 3,420 1

Nested Loop Left Join (cost=209.12..1,701.63 rows=57 width=115) (actual time=3.019..58.766 rows=3,420 loops=1)

19. 4.303 46.798 ↓ 60.0 3,420 1

Nested Loop Left Join (cost=208.83..1,642.41 rows=57 width=81) (actual time=3.014..46.798 rows=3,420 loops=1)

20. 5.312 35.655 ↓ 60.0 3,420 1

Hash Join (cost=208.55..1,613.52 rows=57 width=58) (actual time=3.007..35.655 rows=3,420 loops=1)

  • Hash Cond: (tlsos."tlsostosID" = trec."trectosID")
21. 5.147 27.394 ↓ 60.9 4,994 1

Subquery Scan on tlsos (cost=0.29..1,403.97 rows=82 width=8) (actual time=0.022..27.394 rows=4,994 loops=1)

  • Filter: (tlsos.rr = 1)
  • Rows Removed by Filter: 11378
22. 14.156 22.247 ↑ 1.0 16,372 1

WindowAgg (cost=0.29..1,198.93 rows=16,403 width=20) (actual time=0.017..22.247 rows=16,372 loops=1)

23. 8.091 8.091 ↑ 1.0 16,372 1

Index Scan using idx_tlsos_tlsostosdesc on "TabLogSituacaoOrdemServico" (cost=0.29..911.88 rows=16,403 width=12) (actual time=0.011..8.091 rows=16,372 loops=1)

24. 1.241 2.949 ↑ 1.0 3,420 1

Hash (cost=165.10..165.10 rows=3,453 width=54) (actual time=2.949..2.949 rows=3,420 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 317kB
25. 1.708 1.708 ↑ 1.0 3,437 1

Seq Scan on "TabReceita" trec (cost=0.00..165.10 rows=3,453 width=54) (actual time=0.014..1.708 rows=3,437 loops=1)

  • Filter: ("trectemID" = 1)
  • Rows Removed by Filter: 2910
26. 6.840 6.840 ↑ 1.0 1 3,420

Index Scan using "TabOrdemServico_tosID" on "TabOrdemServico" tos (cost=0.28..0.50 rows=1 width=27) (actual time=0.002..0.002 rows=1 loops=3,420)

  • Index Cond: ("tosID" = trec."trectosID")
27. 6.840 6.840 ↑ 1.0 1 3,420

Index Scan using "TabPropostaComercial_tpcID" on "TabPropostaComercial" tpc (cost=0.28..1.03 rows=1 width=38) (actual time=0.002..0.002 rows=1 loops=3,420)

  • Index Cond: ("tpcID" = tos."tostpcID")
28. 6.840 6.840 ↑ 1.0 1 3,420

Index Scan using "TabFuncionario_tfuID" on "TabFuncionario" tfu (cost=0.27..0.30 rows=1 width=8) (actual time=0.001..0.002 rows=1 loops=3,420)

  • Index Cond: ("tfuID" = tpc."tpctfuID")
29. 6.840 6.840 ↑ 1.0 1 3,420

Index Scan using "TabPessoaID" on "TabPessoa" tpe_funcionario (cost=0.29..3.98 rows=1 width=24) (actual time=0.001..0.002 rows=1 loops=3,420)

  • Index Cond: ("tpeID" = tfu."tfutpeID")
30. 6.840 6.840 ↑ 1.0 1 3,420

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

  • Index Cond: ("tclID" = trec."trectclID")
31. 30.780 30.780 ↓ 2.0 2 3,420

Index Scan using idx_trp_trecid_trpsubstituida on "TabReceitaParcela" trp (cost=0.29..2.03 rows=1 width=294) (actual time=0.006..0.009 rows=2 loops=3,420)

  • Index Cond: (("trptrecID" = trec."trecID") AND ("trpSubstituida" = false))
  • Filter: ((NOT "trpBaixada") AND (NOT "trpSubstituida") AND (NOT "trpPago") AND (NOT "trpEmitidoRemessa") AND ("trpIsExcluido" IS FALSE))
  • Rows Removed by Filter: 9
32. 86.827 86.827 ↑ 1.0 1 6,679

Index Scan using "TabPessoaID" on "TabPessoa" tpe (cost=0.29..1.12 rows=1 width=42) (actual time=0.013..0.013 rows=1 loops=6,679)

  • Index Cond: ("tpeID" = tcl."tcltpeID")
  • Filter: (("tpeCNPJCPF" ~~* '%%'::text) AND (proc_common_remove_acento("tpeNome") ~~* '%%'::text))
33. 13.358 13.358 ↑ 1.0 1 6,679

Index Scan using "TabContaBancaria_tcbID" on "TabContaBancaria" tcb (cost=0.14..0.15 rows=1 width=184) (actual time=0.001..0.002 rows=1 loops=6,679)

  • Index Cond: ("tcbID" = trp."trptcbID")
34. 6.671 6.679 ↑ 1.0 2 6,679

Materialize (cost=0.00..1.03 rows=2 width=40) (actual time=0.000..0.001 rows=2 loops=6,679)

35. 0.008 0.008 ↑ 1.0 2 1

Seq Scan on "TabBancoCarteira" tbc (cost=0.00..1.02 rows=2 width=40) (actual time=0.006..0.008 rows=2 loops=1)

36. 6.673 6.679 ↑ 1.0 4 6,679

Materialize (cost=0.00..1.06 rows=4 width=8) (actual time=0.000..0.001 rows=4 loops=6,679)

37. 0.006 0.006 ↑ 1.0 4 1

Seq Scan on "TabBanco" tba (cost=0.00..1.04 rows=4 width=8) (actual time=0.004..0.006 rows=4 loops=1)

38. 0.000 0.000 ↓ 0.0 0 6,679

Index Scan using "TabTipoBaixa_ttbID" on "TabTipoBaixa" ttb (cost=0.14..0.16 rows=1 width=36) (actual time=0.000..0.000 rows=0 loops=6,679)

  • Index Cond: ("ttbID" = trp."trpTipoBaixa")
39. 0.000 0.000 ↓ 0.0 0 6,679

Index Scan using "TabRemessa_tremID" on "TabRemessa" trem (cost=0.28..0.31 rows=1 width=13) (actual time=0.000..0.000 rows=0 loops=6,679)

  • Index Cond: ("tremID" = trp."trptremID")
40. 0.093 0.203 ↓ 1.1 324 1

Hash (cost=7.05..7.05 rows=305 width=8) (actual time=0.203..0.203 rows=324 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
41. 0.110 0.110 ↓ 1.1 324 1

Seq Scan on "TabCicloFaturamentoOS" tcfos (cost=0.00..7.05 rows=305 width=8) (actual time=0.004..0.110 rows=324 loops=1)

42. 0.096 0.275 ↓ 1.0 313 1

Hash (cost=22.05..22.05 rows=305 width=26) (actual time=0.275..0.275 rows=313 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 26kB
43. 0.179 0.179 ↓ 1.0 313 1

Seq Scan on "TabCycleTransaction" tct (cost=0.00..22.05 rows=305 width=26) (actual time=0.003..0.179 rows=313 loops=1)

44.          

SubPlan (forSubquery Scan)

45. 0.240 0.240 ↑ 1.0 1 40

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.005..0.006 rows=1 loops=40)

46. 0.040 0.040 ↑ 1.0 1 40

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

47. 0.040 0.040 ↑ 1.0 1 40

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

48. 0.360 1.200 ↑ 1.0 1 40

Aggregate (cost=30.30..30.31 rows=1 width=8) (actual time=0.029..0.030 rows=1 loops=40)

49. 0.840 0.840 ↓ 2.0 20 40

Index Scan using idx_trp_trecid_trpsubstituida on "TabReceitaParcela" (cost=0.29..30.27 rows=10 width=4) (actual time=0.008..0.021 rows=20 loops=40)

  • Index Cond: (("trptrecID" = r."trecID") AND ("trpSubstituida" = false))
  • Filter: (("trpSubstituida" IS FALSE) AND ("trptrpOriundaID" IS NULL) AND (NOT "trpIsExcluido"))
  • Rows Removed by Filter: 0
50. 0.040 0.040 ↑ 1.0 1 40

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

51. 0.240 97.600 ↑ 1.0 1 40

Aggregate (cost=256.98..256.99 rows=1 width=8) (actual time=2.439..2.440 rows=1 loops=40)

52. 97.360 97.360 ↑ 1.0 1 40

Seq Scan on "TabClienteContato" tcc (cost=0.00..256.98 rows=1 width=4) (actual time=1.130..2.434 rows=1 loops=40)

  • Filter: (("tccTipoContato" @> '{8}'::integer[]) AND ("tcctclID" = r."tclID"))
  • Rows Removed by Filter: 10721
53. 0.040 0.040 ↑ 1.0 1 40

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

54. 0.360 0.360 ↑ 1.0 1 40

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=40)

55. 0.160 0.160 ↑ 1.0 1 40

Result (cost=0.00..0.02 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=40)

56. 0.120 0.360 ↑ 1.0 1 40

Aggregate (cost=13.65..13.66 rows=1 width=8) (actual time=0.008..0.009 rows=1 loops=40)

57. 0.240 0.240 ↓ 0.0 0 40

Index Scan using idx_tcdcli_tcdclitrpid on "TabClienteDocumento" (cost=0.29..13.64 rows=3 width=4) (actual time=0.006..0.006 rows=0 loops=40)

  • Index Cond: ("tcdclitrpID" = r."trpID")
58. 1.600 1.600 ↑ 1,000.0 1 40

Function Scan on proc_comercial_gettipospagamento (cost=0.25..10.25 rows=1,000 width=32) (actual time=0.040..0.040 rows=1 loops=40)

59. 0.160 2.320 ↓ 0.0 0 40

Limit (cost=0.29..15.15 rows=1 width=4) (actual time=0.058..0.058 rows=0 loops=40)

60. 0.080 2.160 ↓ 0.0 0 40

Nested Loop (cost=0.29..15.15 rows=1 width=4) (actual time=0.054..0.054 rows=0 loops=40)

  • Join Filter: (tcd."tcdDocumento" = tdc."tdcdocID")
61. 1.920 1.920 ↓ 2.0 2 40

Seq Scan on "TabDocumentoCliente" tdc (cost=0.00..1.48 rows=1 width=4) (actual time=0.009..0.048 rows=2 loops=40)

  • Filter: ("tdcdocValor" ~~* 'comprovante_pagamento%'::text)
  • Rows Removed by Filter: 36
62. 0.160 0.160 ↓ 0.0 0 80

Index Scan using idx_tcdcli_tcdclitrpid on "TabClienteDocumento" tcd (cost=0.29..13.64 rows=3 width=8) (actual time=0.002..0.002 rows=0 loops=80)

  • Index Cond: ("tcdclitrpID" = r."trpID")
63. 0.080 1.680 ↓ 0.0 0 40

Limit (cost=0.29..15.15 rows=1 width=4) (actual time=0.042..0.042 rows=0 loops=40)

64. 0.080 1.600 ↓ 0.0 0 40

Nested Loop (cost=0.29..15.15 rows=1 width=4) (actual time=0.040..0.040 rows=0 loops=40)

  • Join Filter: (tcd_1."tcdDocumento" = tdc_1."tdcdocID")
65. 1.440 1.440 ↓ 2.0 2 40

Seq Scan on "TabDocumentoCliente" tdc_1 (cost=0.00..1.48 rows=1 width=4) (actual time=0.030..0.036 rows=2 loops=40)

  • Filter: ("tdcdocValor" ~~* 'nfse%'::text)
  • Rows Removed by Filter: 36
66. 0.080 0.080 ↓ 0.0 0 80

Index Scan using idx_tcdcli_tcdclitrpid on "TabClienteDocumento" tcd_1 (cost=0.29..13.64 rows=3 width=8) (actual time=0.001..0.001 rows=0 loops=80)

  • Index Cond: ("tcdclitrpID" = r."trpID")
67. 2.200 2.200 ↑ 1.0 1 40

Function Scan on proc_common_countbusinessdays (cost=0.25..0.26 rows=1 width=8) (actual time=0.055..0.055 rows=1 loops=40)

68. 0.280 94.240 ↑ 1.0 1 40

Aggregate (cost=256.96..256.97 rows=1 width=8) (actual time=2.356..2.356 rows=1 loops=40)

69. 93.960 93.960 ↑ 1.0 1 40

Seq Scan on "TabEndereco" (cost=0.00..256.96 rows=1 width=4) (actual time=0.710..2.349 rows=1 loops=40)

  • Filter: (("tenTipoEndereco" @> '{1}'::integer[]) AND ("tentpeID" = r."tpeID"))
  • Rows Removed by Filter: 8254
70. 0.200 298.640 ↑ 1.0 1 40

Aggregate (cost=2,085.69..2,085.70 rows=1 width=8) (actual time=7.465..7.466 rows=1 loops=40)

71. 298.440 298.440 ↑ 1.0 2 40

Seq Scan on "TabReceitaParcelaContabil" (cost=0.00..2,085.68 rows=2 width=4) (actual time=1.561..7.461 rows=2 loops=40)

  • Filter: (("trpctrpID" = r."trpID") AND ("trpcTipo" = 1))
  • Rows Removed by Filter: 89210
72. 0.200 285.800 ↑ 1.0 1 40

Aggregate (cost=2,085.69..2,085.70 rows=1 width=8) (actual time=7.145..7.145 rows=1 loops=40)

73. 285.600 285.600 ↓ 0.0 0 40

Seq Scan on "TabReceitaParcelaContabil" "TabReceitaParcelaContabil_1" (cost=0.00..2,085.68 rows=2 width=4) (actual time=7.140..7.140 rows=0 loops=40)

  • Filter: (("trpctrpID" = r."trpID") AND ("trpcTipo" = 2))
  • Rows Removed by Filter: 89212
74. 26.800 26.800 ↑ 1,000.0 1 40

Function Scan on proc_common_getnetxbusinessdays (cost=0.25..10.25 rows=1,000 width=32) (actual time=0.670..0.670 rows=1 loops=40)

75. 0.160 34.520 ↑ 1.0 1 40

Aggregate (cost=203.78..203.79 rows=1 width=8) (actual time=0.862..0.863 rows=1 loops=40)

76. 0.200 34.360 ↑ 1.0 2 40

Nested Loop (cost=0.57..203.78 rows=2 width=4) (actual time=0.486..0.859 rows=2 loops=40)

77. 0.240 33.000 ↑ 1.0 1 40

Nested Loop (cost=0.28..173.41 rows=1 width=4) (actual time=0.467..0.825 rows=1 loops=40)

78. 32.360 32.360 ↑ 1.0 1 40

Seq Scan on "TabReceita" trec_1 (cost=0.00..165.10 rows=1 width=8) (actual time=0.452..0.809 rows=1 loops=40)

  • Filter: ("trectosID" = r."tosID")
  • Rows Removed by Filter: 6346
79. 0.400 0.400 ↑ 1.0 1 40

Index Only Scan using "TabOrdemServico_tosID" on "TabOrdemServico" tos_1 (cost=0.28..8.30 rows=1 width=4) (actual time=0.009..0.010 rows=1 loops=40)

  • Index Cond: ("tosID" = r."tosID")
  • Heap Fetches: 0
80. 1.160 1.160 ↑ 1.0 2 40

Index Scan using idx_trp_trecid_trpsubstituida on "TabReceitaParcela" trp_1 (cost=0.29..30.35 rows=2 width=8) (actual time=0.015..0.029 rows=2 loops=40)

  • Index Cond: (("trptrecID" = trec_1."trecID") AND ("trpSubstituida" = false))
  • Filter: (("trpPago" IS FALSE) AND ("trpBaixada" IS FALSE) AND ("trpSubstituida" IS FALSE) AND (('now'::cstring)::date > "trpDataVencimento"))
  • Rows Removed by Filter: 18
81. 2.920 2.920 ↑ 1,000.0 1 40

Function Scan on proc_comercial_getsituacoesordensservico (cost=0.25..10.25 rows=1,000 width=32) (actual time=0.073..0.073 rows=1 loops=40)

Planning time : 9.004 ms
Execution time : 1,189.988 ms