explain.depesz.com

PostgreSQL's explain analyze made readable

Result: FpSR

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=70,506.27..70,658.77 rows=1,000 width=112) (actual rows= loops=)

  • Group Key: r.grupo, n.grupo, c.grupo, d.grupo, e.grupo, ai.grupo, vd.grupo, esd.grupo, sv.grupo, sm.grupo, sd.grupo, se.grupo, sdv.grupo, sai.grupo
2.          

CTE animais_inicio

3. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.68..8,085.25 rows=1,000 width=8) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Function Scan on obtenha_animais_estoque_por_contrato e_1 (cost=0.25..10.25 rows=1,000 width=4) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_pkey on mbw_animal a (cost=0.43..8.06 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = e_1.animal_id)
6.          

CTE entrada_animais_nascidos

7. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_1 (cost=0.43..7,510.94 rows=74 width=12) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((tipo_id <> ALL ('{7,9}'::integer[])) AND (data_aquisicao_inicial >= '2017-01-01'::date) AND (data_aquisicao_inicial <= '2019-07-05'::date) AND (tipo_entrada_inicial = 0))
8.          

CTE entrada_animais_compra

9. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_2 (cost=0.43..7,510.94 rows=104 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((tipo_id <> ALL ('{7,9}'::integer[])) AND (data_aquisicao_inicial >= '2017-01-01'::date) AND (data_aquisicao_inicial <= '2019-07-05'::date) AND (tipo_entrada_inicial = 1))
10.          

CTE entrada_animais_doacao

11. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_3 (cost=0.43..7,510.94 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((tipo_id <> ALL ('{7,9}'::integer[])) AND (data_aquisicao_inicial >= '2017-01-01'::date) AND (data_aquisicao_inicial <= '2019-07-05'::date) AND (tipo_entrada_inicial = 2))
12.          

CTE entrada_animais_emprestimo

13. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_4 (cost=0.43..7,510.94 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((tipo_id <> ALL ('{7,9}'::integer[])) AND (data_aquisicao_inicial >= '2017-01-01'::date) AND (data_aquisicao_inicial <= '2019-07-05'::date) AND (tipo_entrada_inicial = 3))
14.          

CTE entrada_animais_ajuste_inventario

15. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_5 (cost=0.43..7,510.94 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((tipo_id <> ALL ('{7,9}'::integer[])) AND (data_aquisicao_inicial >= '2017-01-01'::date) AND (data_aquisicao_inicial <= '2019-07-05'::date) AND (tipo_entrada_inicial = 5))
16.          

CTE entrada_venda_devolucoes

17. 0.000 0.000 ↓ 0.0

Nested Loop (cost=20.33..2,916.12 rows=1 width=8) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on mbw_vendaitens vi (cost=19.90..2,907.67 rows=1 width=12) (actual rows= loops=)

  • Recheck Cond: (contrato_id = 120)
  • Filter: ((data_devolucao >= '2017-01-01'::date) AND (data_devolucao <= '2019-07-05'::date))
19. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on mbw_vendaitens_868819a8 (cost=0.00..19.90 rows=997 width=0) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
20. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_6 (cost=0.43..8.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = vi.animal_id)
21.          

CTE entrada_saida_devolucao

22. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.72..148.64 rows=1 width=8) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Index Scan using mbw_saida_868819a8 on mbw_saida s (cost=0.29..140.18 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((data_devolucao >= '2017-01-01'::date) AND (data_devolucao <= '2019-07-05'::date) AND (tipo = ANY ('{2,3,5}'::integer[])))
24. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_7 (cost=0.43..8.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = s.animal_id)
25.          

CTE saida_venda

26. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.14..1,332.84 rows=47 width=8) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.71..1,279.22 rows=47 width=12) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Index Scan using mbw_venda_868819a8 on mbw_venda v (cost=0.29..168.65 rows=6 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date))
29. 0.000 0.000 ↓ 0.0

Index Scan using mbw_vendaitens_2f2a853d on mbw_vendaitens vi_1 (cost=0.42..184.58 rows=51 width=12) (actual rows= loops=)

  • Index Cond: (venda_id = v.id)
30. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_8 (cost=0.43..1.13 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = vi_1.animal_id)
31.          

CTE saida_morte

32. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,218.42..8,715.73 rows=10 width=8) (actual rows= loops=)

  • Hash Cond: (a_9.id = m.animal_id)
33. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_9 (cost=0.43..7,484.32 rows=2,662 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
34. 0.000 0.000 ↓ 0.0

Hash (cost=1,127.89..1,127.89 rows=7,208 width=4) (actual rows= loops=)

35. 0.000 0.000 ↓ 0.0

Seq Scan on mbw_morte m (cost=0.00..1,127.89 rows=7,208 width=4) (actual rows= loops=)

  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date))
36.          

CTE saida_doacao

37. 0.000 0.000 ↓ 0.0

Hash Join (cost=3,511.37..11,031.89 rows=2 width=8) (actual rows= loops=)

  • Hash Cond: (a_10.id = s_1.animal_id)
38. 0.000 0.000 ↓ 0.0

Index Scan using mbw_animal_868819a8 on mbw_animal a_10 (cost=0.43..7,484.32 rows=2,662 width=8) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
39. 0.000 0.000 ↓ 0.0

Hash (cost=3,494.33..3,494.33 rows=1,329 width=8) (actual rows= loops=)

40. 0.000 0.000 ↓ 0.0

Seq Scan on mbw_saida s_1 (cost=0.00..3,494.33 rows=1,329 width=8) (actual rows= loops=)

  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date) AND (tipo = 2))
41.          

CTE saida_emprestimo

42. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.72..148.57 rows=1 width=8) (actual rows= loops=)

43. 0.000 0.000 ↓ 0.0

Index Scan using mbw_saida_868819a8 on mbw_saida s_2 (cost=0.29..140.11 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date) AND (tipo = 3))
44. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_11 (cost=0.43..8.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = s_2.animal_id)
45.          

CTE saida_devolucao

46. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.72..148.57 rows=1 width=8) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Index Scan using mbw_saida_868819a8 on mbw_saida s_3 (cost=0.29..140.11 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date) AND (tipo = 4))
48. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_12 (cost=0.43..8.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = s_3.animal_id)
49.          

CTE saida_ajuste_inventario

50. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.72..283.85 rows=17 width=8) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Index Scan using mbw_saida_868819a8 on mbw_saida s_4 (cost=0.29..140.11 rows=17 width=12) (actual rows= loops=)

  • Index Cond: (contrato_id = 120)
  • Filter: ((data >= '2017-01-01'::date) AND (data <= '2019-07-05'::date) AND (tipo = 5))
52. 0.000 0.000 ↓ 0.0

Index Only Scan using mbw_animal_pkey on mbw_animal a_13 (cost=0.43..8.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = s_4.animal_id)
53. 0.000 0.000 ↓ 0.0

Sort (cost=140.11..142.61 rows=1,000 width=112) (actual rows= loops=)

  • Sort Key: r.grupo, n.grupo, c.grupo, d.grupo, e.grupo, ai.grupo, vd.grupo, esd.grupo, sv.grupo, sm.grupo, sd.grupo, se.grupo, sdv.grupo, sai.grupo
54. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=8.48..90.28 rows=1,000 width=112) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = sai.contrato_id)
55. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=7.93..85.13 rows=1,000 width=108) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = sdv.contrato_id)
56. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=7.90..81.30 rows=1,000 width=100) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = se.contrato_id)
57. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=7.87..77.46 rows=1,000 width=92) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = sd.contrato_id)
58. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=7.80..73.55 rows=1,000 width=84) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = sm.contrato_id)
59. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=7.47..68.97 rows=1,000 width=76) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = sv.contrato_id)
60. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.95..61.35 rows=1,000 width=68) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = esd.contrato_id)
61. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.91..57.51 rows=1,000 width=60) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = vd.contrato_id)
62. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.88..53.68 rows=1,000 width=52) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = ai.contrato_id)
63. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.85..49.85 rows=1,000 width=44) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = e.contrato_id)
64. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.82..46.02 rows=1,000 width=36) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = d.contrato_id)
65. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.79..42.19 rows=1,000 width=28) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = c.contrato_id)
66. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=2.41..29.86 rows=1,000 width=20) (actual rows= loops=)

  • Hash Cond: (r.contrato_id = n.contrato_id)
67. 0.000 0.000 ↓ 0.0

CTE Scan on animais_inicio r (cost=0.00..20.00 rows=1,000 width=12) (actual rows= loops=)

68. 0.000 0.000 ↓ 0.0

Hash (cost=1.48..1.48 rows=74 width=12) (actual rows= loops=)

69. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_animais_nascidos n (cost=0.00..1.48 rows=74 width=12) (actual rows= loops=)

70. 0.000 0.000 ↓ 0.0

Hash (cost=2.08..2.08 rows=104 width=12) (actual rows= loops=)

71. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_animais_compra c (cost=0.00..2.08 rows=104 width=12) (actual rows= loops=)

72. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

73. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_animais_doacao d (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

74. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_animais_emprestimo e (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

76. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

77. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_animais_ajuste_inventario ai (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

78. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

79. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_venda_devolucoes vd (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

80. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

81. 0.000 0.000 ↓ 0.0

CTE Scan on entrada_saida_devolucao esd (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

Hash (cost=0.94..0.94 rows=47 width=12) (actual rows= loops=)

83. 0.000 0.000 ↓ 0.0

CTE Scan on saida_venda sv (cost=0.00..0.94 rows=47 width=12) (actual rows= loops=)

84. 0.000 0.000 ↓ 0.0

Hash (cost=0.20..0.20 rows=10 width=12) (actual rows= loops=)

85. 0.000 0.000 ↓ 0.0

CTE Scan on saida_morte sm (cost=0.00..0.20 rows=10 width=12) (actual rows= loops=)

86. 0.000 0.000 ↓ 0.0

Hash (cost=0.04..0.04 rows=2 width=12) (actual rows= loops=)

87. 0.000 0.000 ↓ 0.0

CTE Scan on saida_doacao sd (cost=0.00..0.04 rows=2 width=12) (actual rows= loops=)

88. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

89. 0.000 0.000 ↓ 0.0

CTE Scan on saida_emprestimo se (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

90. 0.000 0.000 ↓ 0.0

Hash (cost=0.02..0.02 rows=1 width=12) (actual rows= loops=)

91. 0.000 0.000 ↓ 0.0

CTE Scan on saida_devolucao sdv (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

92. 0.000 0.000 ↓ 0.0

Hash (cost=0.34..0.34 rows=17 width=12) (actual rows= loops=)

93. 0.000 0.000 ↓ 0.0

CTE Scan on saida_ajuste_inventario sai (cost=0.00..0.34 rows=17 width=12) (actual rows= loops=)