explain.depesz.com

PostgreSQL's explain analyze made readable

Result: z95

Settings
# exclusive inclusive rows x rows loops node
1. 0.030 150.456 ↓ 5.0 5 1

GroupAggregate (cost=5,751.28..5,751.38 rows=1 width=1,714) (actual time=150.439..150.456 rows=5 loops=1)

  • Group Key: v.id, ((COALESCE(COALESCE(fp.nome, COALESCE(fpf.nome, fpv.nome)), fpi.nome))::character varying(255)), (COALESCE(COALESCE(cm.forma_pagamento_id, COALESCE(f.forma_pagamento_id, vfp.forma_pagamento_venda_id)), fip.forma_pagamento_id)), (COALESCE(fip.parcelas, 1)), (COALESCE(f.vencimento, COALESCE(fip.vencimento, COALESCE(fi.vencimento, v.data_venda)))), (COALESCE(cm.cheque_numero, fip.cheque_numero)), p.nome, f.financeiro_id, (COALESCE(COALESCE(cm.autorizacao_cartao, vfp.autorizacao_cartao), fip.autorizacao_cartao)), (COALESCE(COALESCE(cm.cartao_operadora, vfp.cartao_operadora), fip.operadora)), (COALESCE(COALESCE(cm.cartao_ultimos_digitos, vfp.cartao_ultimos_digitos), fip.cartao_ultimos_digitos)), fi.tipo, (COALESCE(cm.documento, fip.documento)), vendedor.nome, intermediario.nome, fip.financeiro_item_pagamento_id, c.descricao, (COALESCE(fip.cliente_fornecedor, fi.cliente_fornecedor)), e.nome, ((CASE (f.liquidacao IS NULL) WHEN CASE_TEST_EXPR THEN COALESCE((f.observacoes)::text, (fip.detalhes)::text) ELSE ''::text END)::character varying(255)), (COALESCE(cm.banco, (fip.banco)::bpchar)), (COALESCE(cm.cpf_cnpj, fip.cpf_cnpj))
2.          

CTE trechos

3. 80.134 114.704 ↓ 1.1 24,873 1

GroupAggregate (cost=0.29..4,820.34 rows=23,623 width=48) (actual time=0.019..114.704 rows=24,873 loops=1)

  • Group Key: sta.vendas_produtos_id
4. 34.570 34.570 ↑ 1.0 46,449 1

Index Scan using idx_trecho_aereo_vendas_produtos_id on trecho_aereo sta (cost=0.29..3,806.67 rows=47,892 width=40) (actual time=0.005..34.570 rows=46,449 loops=1)

5. 0.025 150.426 ↓ 7.0 7 1

Sort (cost=930.94..930.95 rows=1 width=1,703) (actual time=150.423..150.426 rows=7 loops=1)

  • Sort Key: v.id, ((COALESCE(COALESCE(fp.nome, COALESCE(fpf.nome, fpv.nome)), fpi.nome))::character varying(255)), (COALESCE(COALESCE(cm.forma_pagamento_id, COALESCE(f.forma_pagamento_id, vfp.forma_pagamento_venda_id)), fip.forma_pagamento_id)), (COALESCE(fip.parcelas, 1)), (COALESCE(f.vencimento, COALESCE(fip.vencimento, COALESCE(fi.vencimento, v.data_venda)))), (COALESCE(cm.cheque_numero, fip.cheque_numero)), p.nome, f.financeiro_id, (COALESCE(COALESCE(cm.autorizacao_cartao, vfp.autorizacao_cartao), fip.autorizacao_cartao)), (COALESCE(COALESCE(cm.cartao_operadora, vfp.cartao_operadora), fip.operadora)), (COALESCE(COALESCE(cm.cartao_ultimos_digitos, vfp.cartao_ultimos_digitos), fip.cartao_ultimos_digitos)), fi.tipo, (COALESCE(cm.documento, fip.documento)), vendedor.nome, intermediario.nome, fip.financeiro_item_pagamento_id, c.descricao, (COALESCE(fip.cliente_fornecedor, fi.cliente_fornecedor)), e.nome, ((CASE (f.liquidacao IS NULL) WHEN CASE_TEST_EXPR THEN COALESCE((f.observacoes)::text, (fip.detalhes)::text) ELSE ''::text END)::character varying(255)), (COALESCE(cm.banco, (fip.banco)::bpchar)), (COALESCE(cm.cpf_cnpj, fip.cpf_cnpj))
  • Sort Method: quicksort Memory: 26kB
6. 0.019 150.401 ↓ 7.0 7 1

Nested Loop Left Join (cost=369.67..930.93 rows=1 width=1,703) (actual time=135.682..150.401 rows=7 loops=1)

7. 0.016 150.375 ↓ 7.0 7 1

Nested Loop Left Join (cost=369.53..930.76 rows=1 width=1,007) (actual time=135.673..150.375 rows=7 loops=1)

  • Join Filter: (f.liquidacao IS NULL)
8. 0.012 150.338 ↓ 7.0 7 1

Nested Loop Left Join (cost=369.12..930.22 rows=1 width=971) (actual time=135.669..150.338 rows=7 loops=1)

9. 0.019 150.319 ↓ 7.0 7 1

Nested Loop Left Join (cost=368.98..930.06 rows=1 width=893) (actual time=135.665..150.319 rows=7 loops=1)

10. 11.010 150.293 ↓ 7.0 7 1

Hash Right Join (cost=368.70..929.76 rows=1 width=735) (actual time=135.657..150.293 rows=7 loops=1)

  • Hash Cond: (t.vendas_produtos_id = vpr.vendas_produtos_id)
11. 138.544 138.544 ↓ 1.1 24,873 1

CTE Scan on trechos t (cost=0.00..472.46 rows=23,623 width=48) (actual time=0.021..138.544 rows=24,873 loops=1)

12. 0.009 0.739 ↓ 7.0 7 1

Hash (cost=368.69..368.69 rows=1 width=719) (actual time=0.739..0.739 rows=7 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
13. 0.009 0.730 ↓ 7.0 7 1

Nested Loop Left Join (cost=7.84..368.69 rows=1 width=719) (actual time=0.166..0.730 rows=7 loops=1)

14. 0.012 0.714 ↓ 7.0 7 1

Nested Loop Left Join (cost=7.56..360.39 rows=1 width=714) (actual time=0.163..0.714 rows=7 loops=1)

15. 0.060 0.688 ↓ 7.0 7 1

Nested Loop Left Join (cost=7.27..352.08 rows=1 width=693) (actual time=0.156..0.688 rows=7 loops=1)

  • Join Filter: (cm.forma_pagamento_id = fp.forma_pagamento_id)
  • Rows Removed by Join Filter: 112
16. 0.164 0.579 ↓ 7.0 7 1

Nested Loop Left Join (cost=7.27..350.72 rows=1 width=615) (actual time=0.139..0.579 rows=7 loops=1)

  • Join Filter: (c.conta_id = cm.conta_id)
  • Rows Removed by Join Filter: 364
17. 0.012 0.268 ↓ 7.0 7 1

Nested Loop Left Join (cost=7.27..348.55 rows=1 width=513) (actual time=0.092..0.268 rows=7 loops=1)

18. 0.057 0.242 ↓ 7.0 7 1

Nested Loop Left Join (cost=6.85..348.03 rows=1 width=382) (actual time=0.086..0.242 rows=7 loops=1)

  • Join Filter: (f.forma_pagamento_id = fpf.forma_pagamento_id)
  • Rows Removed by Join Filter: 112
19. 0.017 0.129 ↓ 7.0 7 1

Nested Loop Left Join (cost=6.85..346.67 rows=1 width=304) (actual time=0.066..0.129 rows=7 loops=1)

  • Filter: (COALESCE((f.cancelado)::bpchar, '0'::bpchar) = '0'::bpchar)
20. 0.009 0.098 ↑ 4.6 7 1

Nested Loop (cost=6.43..323.96 rows=32 width=180) (actual time=0.058..0.098 rows=7 loops=1)

21. 0.004 0.071 ↑ 11.0 2 1

Nested Loop (cost=6.01..307.60 rows=22 width=132) (actual time=0.049..0.071 rows=2 loops=1)

22. 0.004 0.061 ↑ 11.0 2 1

Nested Loop (cost=5.73..287.70 rows=22 width=148) (actual time=0.044..0.061 rows=2 loops=1)

23. 0.005 0.051 ↑ 11.0 2 1

Nested Loop (cost=5.44..280.96 rows=22 width=148) (actual time=0.039..0.051 rows=2 loops=1)

24. 0.005 0.042 ↑ 11.0 2 1

Nested Loop (cost=5.30..277.43 rows=22 width=164) (actual time=0.034..0.042 rows=2 loops=1)

25. 0.003 0.026 ↑ 9.0 1 1

Nested Loop (cost=0.86..130.83 rows=9 width=116) (actual time=0.022..0.026 rows=1 loops=1)

26. 0.007 0.007 ↑ 1.0 1 1

Index Scan using pk_pessoa on pessoa e (cost=0.29..8.30 rows=1 width=37) (actual time=0.006..0.007 rows=1 loops=1)

  • Index Cond: (pessoa_id = '175589fb-5eaf-4c5a-934a-6e55c546ac2d'::uuid)
27. 0.003 0.016 ↑ 9.0 1 1

Nested Loop (cost=0.57..122.43 rows=9 width=95) (actual time=0.014..0.016 rows=1 loops=1)

28. 0.009 0.009 ↑ 9.0 1 1

Index Scan using idx_data_venda on vendas v (cost=0.29..47.69 rows=9 width=90) (actual time=0.008..0.009 rows=1 loops=1)

  • Index Cond: ((data_venda >= '2019-09-27'::date) AND (data_venda <= '2019-09-27'::date))
  • Filter: ((situacao = ANY ('{A,F}'::bpchar[])) AND (empresa_id = '175589fb-5eaf-4c5a-934a-6e55c546ac2d'::uuid))
29. 0.004 0.004 ↑ 1.0 1 1

Index Scan using pk_pessoa on pessoa p (cost=0.29..8.30 rows=1 width=37) (actual time=0.003..0.004 rows=1 loops=1)

  • Index Cond: (pessoa_id = v.pagante_id)
30. 0.006 0.011 ↑ 1.5 2 1

Bitmap Heap Scan on vendas_produtos vpr (cost=4.44..16.26 rows=3 width=80) (actual time=0.008..0.011 rows=2 loops=1)

  • Recheck Cond: (vendas_id = v.id)
  • Heap Blocks: exact=2
31. 0.005 0.005 ↑ 1.5 2 1

Bitmap Index Scan on idx_vendas_produtos_vendas_id (cost=0.00..4.44 rows=3 width=0) (actual time=0.005..0.005 rows=2 loops=1)

  • Index Cond: (vendas_id = v.id)
32. 0.004 0.004 ↑ 1.0 1 2

Index Only Scan using pk_produtos on produtos pr (cost=0.14..0.16 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=2)

  • Index Cond: (id = vpr.produto_id)
  • Heap Fetches: 0
33. 0.006 0.006 ↑ 1.0 1 2

Index Scan using pk_fornecimento on fornecimento fn (cost=0.28..0.31 rows=1 width=32) (actual time=0.003..0.003 rows=1 loops=2)

  • Index Cond: (fornecimento_id = vpr.fornecimento_id)
34. 0.006 0.006 ↑ 1.0 1 2

Index Only Scan using pk_pessoa on pessoa pf (cost=0.29..0.90 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=2)

  • Index Cond: (pessoa_id = fn.fornecedor_id)
  • Heap Fetches: 2
35. 0.018 0.018 ↓ 2.0 4 2

Index Scan using idx_financeiro_item_vendas_produtos_id on financeiro_item fi (cost=0.42..0.72 rows=2 width=64) (actual time=0.005..0.009 rows=4 loops=2)

  • Index Cond: (vendas_produtos_id = vpr.vendas_produtos_id)
  • Filter: ((tipo <> 'SAL'::bpchar) AND (tipo <> 'RMB'::bpchar) AND (cliente_fornecedor = 'C'::bpchar))
  • Rows Removed by Filter: 1
36. 0.014 0.014 ↑ 1.0 1 7

Index Scan using pk_financeiro on financeiro f (cost=0.42..0.70 rows=1 width=142) (actual time=0.002..0.002 rows=1 loops=7)

  • Index Cond: (fi.financeiro_id = financeiro_id)
37. 0.056 0.056 ↑ 1.0 16 7

Seq Scan on forma_pagamento fpf (cost=0.00..1.16 rows=16 width=94) (actual time=0.002..0.008 rows=16 loops=7)

38. 0.014 0.014 ↓ 0.0 0 7

Index Scan using idx_conta_movimento_financeiro_id on conta_movimento cm (cost=0.42..0.51 rows=1 width=147) (actual time=0.002..0.002 rows=0 loops=7)

  • Index Cond: (financeiro_id = f.financeiro_id)
39. 0.147 0.147 ↑ 1.0 52 7

Seq Scan on conta c (cost=0.00..1.52 rows=52 width=134) (actual time=0.001..0.021 rows=52 loops=7)

40. 0.049 0.049 ↑ 1.0 16 7

Seq Scan on forma_pagamento fp (cost=0.00..1.16 rows=16 width=94) (actual time=0.001..0.007 rows=16 loops=7)

41. 0.014 0.014 ↑ 1.0 1 7

Index Scan using pk_pessoa on pessoa vendedor (cost=0.29..8.30 rows=1 width=37) (actual time=0.002..0.002 rows=1 loops=7)

  • Index Cond: (v.vendedor_id = pessoa_id)
42. 0.007 0.007 ↓ 0.0 0 7

Index Scan using pk_pessoa on pessoa intermediario (cost=0.29..8.30 rows=1 width=37) (actual time=0.000..0.001 rows=0 loops=7)

  • Index Cond: (v.intermediario_id = pessoa_id)
43. 0.007 0.007 ↓ 0.0 0 7

Index Scan using pk_financeiro_item_cartao on financeiro_item_pagamento fip (cost=0.28..0.30 rows=1 width=174) (actual time=0.001..0.001 rows=0 loops=7)

  • Index Cond: (fi.financeiro_item_pagamento_id = financeiro_item_pagamento_id)
44. 0.007 0.007 ↓ 0.0 0 7

Index Scan using pk_forma_pagamento on forma_pagamento fpi (cost=0.14..0.16 rows=1 width=94) (actual time=0.001..0.001 rows=0 loops=7)

  • Index Cond: (fip.forma_pagamento_id = forma_pagamento_id)
45. 0.021 0.021 ↓ 0.0 0 7

Index Scan using idx_vendas_pagamentos_financeiro_id on vendas_pagamentos vfp (cost=0.41..0.53 rows=1 width=52) (actual time=0.003..0.003 rows=0 loops=7)

  • Index Cond: (financeiro_id = f.financeiro_id)
  • Filter: (forma_pagamento_venda_id = '13b49005-3505-40c0-8043-978813f9c941'::uuid)
46. 0.007 0.007 ↓ 0.0 0 7

Index Scan using pk_forma_pagamento_venda on forma_pagamento_venda fpv (cost=0.14..0.16 rows=1 width=134) (actual time=0.001..0.001 rows=0 loops=7)

  • Index Cond: ((forma_pagamento_venda_id = vfp.forma_pagamento_venda_id) AND (forma_pagamento_venda_id = '13b49005-3505-40c0-8043-978813f9c941'::uuid))
Planning time : 5.761 ms
Execution time : 151.320 ms