explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 57Ky

Settings
# exclusive inclusive rows x rows loops node
1. 2.572 1,164.759 ↓ 1.2 6,809 1

Append (cost=239.42..157,293.96 rows=5,828 width=570) (actual time=8.740..1,164.759 rows=6,809 loops=1)

2. 11.986 944.137 ↑ 1.0 5,433 1

Subquery Scan on *SELECT* 1 (cost=239.42..121,046.86 rows=5,436 width=473) (actual time=8.739..944.137 rows=5,433 loops=1)

3. 427.608 932.151 ↑ 1.0 5,433 1

Hash Join (cost=239.42..120,978.91 rows=5,436 width=449) (actual time=8.736..932.151 rows=5,433 loops=1)

  • Hash Cond: (b.iditem = c.iditem)
4. 20.709 40.256 ↑ 1.0 5,433 1

Hash Join (cost=144.97..326.87 rows=5,436 width=111) (actual time=6.020..40.256 rows=5,433 loops=1)

  • Hash Cond: (b.idvenda = a.idvenda)
5. 13.609 13.609 ↑ 1.0 5,455 1

Seq Scan on vendaitem b (cost=0.00..167.55 rows=5,455 width=77) (actual time=0.032..13.609 rows=5,455 loops=1)

  • Filter: (NOT excluido)
6. 2.370 5.938 ↑ 1.0 3,353 1

Hash (cost=103.06..103.06 rows=3,353 width=42) (actual time=5.938..5.938 rows=3,353 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 271kB
7. 3.568 3.568 ↑ 1.0 3,353 1

Seq Scan on venda a (cost=0.00..103.06 rows=3,353 width=42) (actual time=0.026..3.568 rows=3,353 loops=1)

  • Filter: ((NOT excluido) AND ((situacao)::text = 'FECHADO'::text))
  • Rows Removed by Filter: 12
8. 0.897 2.482 ↑ 1.0 2,331 1

Hash (cost=65.31..65.31 rows=2,331 width=16) (actual time=2.482..2.482 rows=2,331 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 142kB
9. 1.585 1.585 ↑ 1.0 2,331 1

Seq Scan on item c (cost=0.00..65.31 rows=2,331 width=16) (actual time=0.039..1.585 rows=2,331 loops=1)

  • Filter: (NOT excluido)
10.          

SubPlan (for Hash Join)

11. 5.433 5.433 ↓ 0.0 0 5,433

Index Scan using pessoa_pk on pessoa x (cost=0.27..8.29 rows=1 width=21) (actual time=0.001..0.001 rows=0 loops=5,433)

  • Index Cond: (idpessoa = b.idprofissional)
12. 76.062 76.062 ↑ 1.0 1 5,433

Seq Scan on subgrupo x_1 (cost=0.00..1.51 rows=1 width=8) (actual time=0.006..0.014 rows=1 loops=5,433)

  • Filter: (idsubgrupo = c.idsubgrupo)
  • Rows Removed by Filter: 40
13. 141.258 228.186 ↑ 1.0 1 5,433

Seq Scan on grupo x_2 (cost=1.51..2.56 rows=1 width=12) (actual time=0.041..0.042 rows=1 loops=5,433)

  • Filter: (idgrupo = $3)
  • Rows Removed by Filter: 3
14.          

Initplan (for Seq Scan)

15. 86.928 86.928 ↑ 1.0 1 5,433

Seq Scan on subgrupo z (cost=0.00..1.51 rows=1 width=8) (actual time=0.006..0.016 rows=1 loops=5,433)

  • Filter: (idsubgrupo = c.idsubgrupo)
  • Rows Removed by Filter: 40
16. 92.361 92.361 ↑ 1.0 1 5,433

Seq Scan on subgrupo x_3 (cost=0.00..1.51 rows=1 width=10) (actual time=0.006..0.017 rows=1 loops=5,433)

  • Filter: (idsubgrupo = c.idsubgrupo)
  • Rows Removed by Filter: 40
17. 59.763 59.763 ↑ 1.0 1 5,433

Index Scan using produto_pk on produto x_4 (cost=0.28..8.30 rows=1 width=8) (actual time=0.010..0.011 rows=1 loops=5,433)

  • Index Cond: (idproduto = c.iditem)
18. 0.150 16.278 ↑ 1.0 195 1

Subquery Scan on *SELECT* 2 (cost=106.16..2,821.72 rows=195 width=523) (actual time=1.720..16.278 rows=195 loops=1)

19. 7.461 16.128 ↑ 1.0 195 1

Hash Join (cost=106.16..2,818.31 rows=195 width=487) (actual time=1.717..16.128 rows=195 loops=1)

  • Hash Cond: (c_1.idplano = d.iditem)
20. 0.297 0.721 ↑ 1.0 195 1

Hash Join (cost=11.71..17.23 rows=195 width=37) (actual time=0.274..0.721 rows=195 loops=1)

  • Hash Cond: ((b_1.idcontratoplano = c_1.idcontratoplano) AND (b_1.versaocontratoplano = c_1.versao))
21. 0.141 0.327 ↑ 1.0 195 1

Hash Join (cost=6.39..10.86 rows=195 width=29) (actual time=0.144..0.327 rows=195 loops=1)

  • Hash Cond: (a_1.idcontratoplanociclo = b_1.idcontratoplanociclo)
22. 0.078 0.078 ↑ 1.0 195 1

Seq Scan on faturamentoplano a_1 (cost=0.00..3.95 rows=195 width=21) (actual time=0.017..0.078 rows=195 loops=1)

  • Filter: (NOT excluido)
23. 0.052 0.108 ↑ 1.0 195 1

Hash (cost=3.95..3.95 rows=195 width=24) (actual time=0.108..0.108 rows=195 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 20kB
24. 0.056 0.056 ↑ 1.0 195 1

Seq Scan on contratoplanociclo b_1 (cost=0.00..3.95 rows=195 width=24) (actual time=0.017..0.056 rows=195 loops=1)

  • Filter: (NOT excluido)
25. 0.039 0.097 ↑ 1.0 93 1

Hash (cost=3.93..3.93 rows=93 width=32) (actual time=0.097..0.097 rows=93 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 15kB
26. 0.058 0.058 ↑ 1.0 93 1

Seq Scan on contratoplano c_1 (cost=0.00..3.93 rows=93 width=32) (actual time=0.018..0.058 rows=93 loops=1)

  • Filter: (NOT excluido)
27. 0.637 1.316 ↑ 1.0 2,331 1

Hash (cost=65.31..65.31 rows=2,331 width=43) (actual time=1.316..1.316 rows=2,331 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 213kB
28. 0.679 0.679 ↑ 1.0 2,331 1

Seq Scan on item d (cost=0.00..65.31 rows=2,331 width=43) (actual time=0.017..0.679 rows=2,331 loops=1)

  • Filter: (NOT excluido)
29.          

SubPlan (for Hash Join)

30. 0.585 0.585 ↑ 1.0 1 195

Index Scan using pessoa_pk on pessoa x_5 (cost=0.27..8.29 rows=1 width=21) (actual time=0.003..0.003 rows=1 loops=195)

  • Index Cond: (idpessoa = c_1.idcliente)
31. 1.170 1.170 ↑ 1.0 1 195

Seq Scan on subgrupo x_6 (cost=0.00..1.51 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=195)

  • Filter: (idsubgrupo = d.idsubgrupo)
  • Rows Removed by Filter: 40
32. 2.535 3.705 ↑ 1.0 1 195

Seq Scan on grupo x_7 (cost=1.51..2.56 rows=1 width=12) (actual time=0.019..0.019 rows=1 loops=195)

  • Filter: (idgrupo = $9)
  • Rows Removed by Filter: 3
33.          

Initplan (for Seq Scan)

34. 1.170 1.170 ↑ 1.0 1 195

Seq Scan on subgrupo z_1 (cost=0.00..1.51 rows=1 width=8) (actual time=0.005..0.006 rows=1 loops=195)

  • Filter: (idsubgrupo = d.idsubgrupo)
  • Rows Removed by Filter: 40
35. 1.170 1.170 ↑ 1.0 1 195

Seq Scan on subgrupo x_8 (cost=0.00..1.51 rows=1 width=10) (actual time=0.005..0.006 rows=1 loops=195)

  • Filter: (idsubgrupo = d.idsubgrupo)
  • Rows Removed by Filter: 40
36. 0.516 101.412 ↓ 6.5 588 1

Subquery Scan on *SELECT* 3 (cost=29.73..15,443.31 rows=91 width=709) (actual time=0.314..101.412 rows=588 loops=1)

37. 31.631 100.896 ↓ 6.5 588 1

Nested Loop (cost=29.73..15,441.72 rows=91 width=677) (actual time=0.312..100.896 rows=588 loops=1)

38. 0.460 22.813 ↓ 6.5 588 1

Hash Anti Join (cost=29.45..10,987.96 rows=91 width=62) (actual time=0.136..22.813 rows=588 loops=1)

  • Hash Cond: (a_2.idatendimento = d_1.idatendimento)
39. 1.168 22.338 ↓ 3.2 588 1

Nested Loop (cost=0.28..10,950.70 rows=182 width=62) (actual time=0.096..22.338 rows=588 loops=1)

40. 0.345 0.345 ↑ 1.0 595 1

Seq Scan on atendimentoproduto b_2 (cost=0.00..14.95 rows=595 width=38) (actual time=0.019..0.345 rows=595 loops=1)

  • Filter: (NOT excluido)
41. 4.361 20.825 ↑ 1.0 1 595

Index Scan using atendimento_pk on atendimento a_2 (cost=0.28..18.38 rows=1 width=32) (actual time=0.035..0.035 rows=1 loops=595)

  • Index Cond: (idatendimento = b_2.idatendimento)
  • Filter: ((NOT excluido) AND ((situacao)::text = 'CHECKOUT'::text) AND ((COALESCE((SubPlan 21), '0'::numeric) + COALESCE((SubPlan 22), '0'::numeric)) > '0'::numeric))
  • Rows Removed by Filter: 0
42.          

SubPlan (for Index Scan)

43. 8.820 13.524 ↑ 1.0 1 588

Aggregate (cost=9.49..9.50 rows=1 width=32) (actual time=0.023..0.023 rows=1 loops=588)

44. 2.940 4.704 ↓ 1.5 3 588

Bitmap Heap Scan on atendimentoproduto x_17 (cost=4.29..9.49 rows=2 width=5) (actual time=0.006..0.008 rows=3 loops=588)

  • Recheck Cond: (idatendimento = a_2.idatendimento)
  • Filter: (NOT excluido)
  • Heap Blocks: exact=1,465
45. 1.764 1.764 ↓ 1.5 3 588

Bitmap Index Scan on idx_atendimentoservico_idatendimento (cost=0.00..4.29 rows=2 width=0) (actual time=0.003..0.003 rows=3 loops=588)

  • Index Cond: (idatendimento = a_2.idatendimento)
46. 1.176 2.940 ↑ 1.0 1 588

Aggregate (cost=8.30..8.31 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=588)

47. 1.764 1.764 ↑ 1.0 1 588

Index Scan using idx_atendimentoservico1_idatendimento on atendimentoservico x_18 (cost=0.28..8.29 rows=1 width=3) (actual time=0.003..0.003 rows=1 loops=588)

  • Index Cond: (idatendimento = a_2.idatendimento)
  • Filter: (NOT excluido)
48. 0.001 0.015 ↓ 0.0 0 1

Hash (cost=21.80..21.80 rows=590 width=8) (actual time=0.015..0.015 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
49. 0.014 0.014 ↓ 0.0 0 1

Seq Scan on atendimentovenda d_1 (cost=0.00..21.80 rows=590 width=8) (actual time=0.014..0.014 rows=0 loops=1)

  • Filter: (NOT excluido)
50. 2.352 2.352 ↑ 1.0 1 588

Index Scan using item_pk on item c_2 (cost=0.28..0.64 rows=1 width=43) (actual time=0.004..0.004 rows=1 loops=588)

  • Index Cond: (iditem = b_2.idproduto)
  • Filter: (NOT excluido)
51.          

SubPlan (for Nested Loop)

52. 1.764 1.764 ↑ 1.0 1 588

Index Scan using pessoa_pk on pessoa x_9 (cost=0.27..8.29 rows=1 width=21) (actual time=0.003..0.003 rows=1 loops=588)

  • Index Cond: (idpessoa = a_2.idcliente)
53. 1.764 1.764 ↑ 1.0 1 588

Index Scan using pessoa_pk on pessoa x_10 (cost=0.27..8.29 rows=1 width=21) (actual time=0.003..0.003 rows=1 loops=588)

  • Index Cond: (idpessoa = b_2.idprofissional)
54. 4.116 4.116 ↑ 1.0 1 588

Seq Scan on subgrupo x_11 (cost=0.00..1.51 rows=1 width=8) (actual time=0.003..0.007 rows=1 loops=588)

  • Filter: (idsubgrupo = c_2.idsubgrupo)
  • Rows Removed by Filter: 40
55. 8.232 12.348 ↑ 1.0 1 588

Seq Scan on grupo x_12 (cost=1.51..2.56 rows=1 width=12) (actual time=0.020..0.021 rows=1 loops=588)

  • Filter: (idgrupo = $15)
  • Rows Removed by Filter: 3
56.          

Initplan (for Seq Scan)

57. 4.116 4.116 ↑ 1.0 1 588

Seq Scan on subgrupo z_2 (cost=0.00..1.51 rows=1 width=8) (actual time=0.003..0.007 rows=1 loops=588)

  • Filter: (idsubgrupo = c_2.idsubgrupo)
  • Rows Removed by Filter: 40
58. 4.116 4.116 ↑ 1.0 1 588

Seq Scan on subgrupo x_13 (cost=0.00..1.51 rows=1 width=10) (actual time=0.003..0.007 rows=1 loops=588)

  • Filter: (idsubgrupo = c_2.idsubgrupo)
  • Rows Removed by Filter: 40
59. 2.352 2.352 ↑ 1.0 1 588

Index Scan using produto_pk on produto x_14 (cost=0.28..8.30 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=588)

  • Index Cond: (idproduto = c_2.iditem)
60. 9.996 14.700 ↑ 1.0 1 588

Aggregate (cost=9.49..9.50 rows=1 width=32) (actual time=0.024..0.025 rows=1 loops=588)

61. 2.352 4.704 ↓ 1.5 3 588

Bitmap Heap Scan on atendimentoproduto x_15 (cost=4.29..9.49 rows=2 width=5) (actual time=0.006..0.008 rows=3 loops=588)

  • Recheck Cond: (idatendimento = a_2.idatendimento)
  • Filter: (NOT excluido)
  • Heap Blocks: exact=1,465
62. 2.352 2.352 ↓ 1.5 3 588

Bitmap Index Scan on idx_atendimentoservico_idatendimento (cost=0.00..4.29 rows=2 width=0) (actual time=0.004..0.004 rows=3 loops=588)

  • Index Cond: (idatendimento = a_2.idatendimento)
63. 1.176 2.940 ↑ 1.0 1 588

Aggregate (cost=8.30..8.31 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=588)

64. 1.764 1.764 ↑ 1.0 1 588

Index Scan using idx_atendimentoservico1_idatendimento on atendimentoservico x_16 (cost=0.28..8.29 rows=1 width=3) (actual time=0.003..0.003 rows=1 loops=588)

  • Index Cond: (idatendimento = a_2.idatendimento)
  • Filter: (NOT excluido)
65. 0.379 100.360 ↓ 5.6 593 1

Subquery Scan on *SELECT* 4 (cost=29.73..17,952.94 rows=106 width=707) (actual time=0.235..100.360 rows=593 loops=1)

66. 31.801 99.981 ↓ 5.6 593 1

Nested Loop (cost=29.73..17,951.08 rows=106 width=675) (actual time=0.233..99.981 rows=593 loops=1)

67. 0.566 23.705 ↓ 5.6 593 1

Hash Anti Join (cost=29.45..12,768.32 rows=106 width=60) (actual time=0.105..23.705 rows=593 loops=1)

  • Hash Cond: (a_3.idatendimento = d_2.idatendimento)
68. 1.563 23.124 ↓ 2.8 593 1

Nested Loop (cost=0.28..12,729.72 rows=213 width=60) (actual time=0.060..23.124 rows=593 loops=1)

69. 0.771 0.771 ↑ 1.0 693 1

Seq Scan on atendimentoservico b_3 (cost=0.00..36.56 rows=693 width=36) (actual time=0.017..0.771 rows=693 loops=1)

  • Filter: ((NOT excluido) AND (idcontratoplanociclo IS NULL))
  • Rows Removed by Filter: 663
70. 3.916 20.790 ↑ 1.0 1 693

Index Scan using atendimento_pk on atendimento a_3 (cost=0.28..18.34 rows=1 width=32) (actual time=0.030..0.030 rows=1 loops=693)

  • Index Cond: (idatendimento = b_3.idatendimento)
  • Filter: ((NOT excluido) AND ((situacao)::text = 'CHECKOUT'::text) AND ((COALESCE((SubPlan 32), '0'::numeric) + COALESCE((SubPlan 33), '0'::numeric)) > '0'::numeric))
  • Rows Removed by Filter: 0
71.          

SubPlan (for Index Scan)

72. 10.384 13.629 ↑ 1.0 1 649

Aggregate (cost=9.49..9.50 rows=1 width=32) (actual time=0.020..0.021 rows=1 loops=649)

73. 1.298 3.245 ↑ 2.0 1 649

Bitmap Heap Scan on atendimentoproduto x_27 (cost=4.29..9.49 rows=2 width=5) (actual time=0.005..0.005 rows=1 loops=649)

  • Recheck Cond: (idatendimento = a_3.idatendimento)
  • Filter: (NOT excluido)
  • Heap Blocks: exact=513
74. 1.947 1.947 ↑ 2.0 1 649

Bitmap Index Scan on idx_atendimentoservico_idatendimento (cost=0.00..4.29 rows=2 width=0) (actual time=0.003..0.003 rows=1 loops=649)

  • Index Cond: (idatendimento = a_3.idatendimento)
75. 1.298 3.245 ↑ 1.0 1 649

Aggregate (cost=8.30..8.31 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=649)

76. 1.947 1.947 ↑ 1.0 1 649

Index Scan using idx_atendimentoservico1_idatendimento on atendimentoservico x_28 (cost=0.28..8.29 rows=1 width=3) (actual time=0.003..0.003 rows=1 loops=649)

  • Index Cond: (idatendimento = a_3.idatendimento)
  • Filter: (NOT excluido)
77. 0.001 0.015 ↓ 0.0 0 1

Hash (cost=21.80..21.80 rows=590 width=8) (actual time=0.015..0.015 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
78. 0.014 0.014 ↓ 0.0 0 1

Seq Scan on atendimentovenda d_2 (cost=0.00..21.80 rows=590 width=8) (actual time=0.014..0.014 rows=0 loops=1)

  • Filter: (NOT excluido)
79. 1.779 1.779 ↑ 1.0 1 593

Index Scan using item_pk on item c_3 (cost=0.28..0.59 rows=1 width=43) (actual time=0.003..0.003 rows=1 loops=593)

  • Index Cond: (iditem = b_3.idservico)
  • Filter: (NOT excluido)
80.          

SubPlan (for Nested Loop)

81. 2.372 2.372 ↑ 1.0 1 593

Index Scan using pessoa_pk on pessoa x_19 (cost=0.27..8.29 rows=1 width=21) (actual time=0.003..0.004 rows=1 loops=593)

  • Index Cond: (idpessoa = a_3.idcliente)
82. 1.779 1.779 ↑ 1.0 1 593

Index Scan using pessoa_pk on pessoa x_20 (cost=0.27..8.29 rows=1 width=21) (actual time=0.003..0.003 rows=1 loops=593)

  • Index Cond: (idpessoa = b_3.idprofissional)
83. 5.930 5.930 ↑ 1.0 1 593

Seq Scan on subgrupo x_21 (cost=0.00..1.51 rows=1 width=8) (actual time=0.007..0.010 rows=1 loops=593)

  • Filter: (idsubgrupo = c_3.idsubgrupo)
  • Rows Removed by Filter: 40
84. 8.302 12.453 ↑ 1.0 1 593

Seq Scan on grupo x_22 (cost=1.51..2.56 rows=1 width=12) (actual time=0.020..0.021 rows=1 loops=593)

  • Filter: (idgrupo = $26)
  • Rows Removed by Filter: 3
85.          

Initplan (for Seq Scan)

86. 4.151 4.151 ↑ 1.0 1 593

Seq Scan on subgrupo z_3 (cost=0.00..1.51 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=593)

  • Filter: (idsubgrupo = c_3.idsubgrupo)
  • Rows Removed by Filter: 40
87. 4.151 4.151 ↑ 1.0 1 593

Seq Scan on subgrupo x_23 (cost=0.00..1.51 rows=1 width=10) (actual time=0.006..0.007 rows=1 loops=593)

  • Filter: (idsubgrupo = c_3.idsubgrupo)
  • Rows Removed by Filter: 40
88. 1.186 1.186 ↓ 0.0 0 593

Index Scan using produto_pk on produto x_24 (cost=0.28..8.30 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=593)

  • Index Cond: (idproduto = c_3.iditem)
89. 8.895 11.860 ↑ 1.0 1 593

Aggregate (cost=9.49..9.50 rows=1 width=32) (actual time=0.020..0.020 rows=1 loops=593)

90. 1.186 2.965 ↑ 2.0 1 593

Bitmap Heap Scan on atendimentoproduto x_25 (cost=4.29..9.49 rows=2 width=5) (actual time=0.005..0.005 rows=1 loops=593)

  • Recheck Cond: (idatendimento = a_3.idatendimento)
  • Filter: (NOT excluido)
  • Heap Blocks: exact=513
91. 1.779 1.779 ↑ 2.0 1 593

Bitmap Index Scan on idx_atendimentoservico_idatendimento (cost=0.00..4.29 rows=2 width=0) (actual time=0.003..0.003 rows=1 loops=593)

  • Index Cond: (idatendimento = a_3.idatendimento)
92. 1.186 2.965 ↑ 1.0 1 593

Aggregate (cost=8.30..8.31 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=593)

93. 1.779 1.779 ↑ 1.0 1 593

Index Scan using idx_atendimentoservico1_idatendimento on atendimentoservico x_26 (cost=0.28..8.29 rows=1 width=3) (actual time=0.003..0.003 rows=1 loops=593)

  • Index Cond: (idatendimento = a_3.idatendimento)
  • Filter: (NOT excluido)