explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2MXxF : Optimization for: plan #VUQj

Settings

Optimization path:

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

Sort (cost=26,930.08..26,930.08 rows=1 width=2,311) (actual rows= loops=)

  • Sort Key: contratos.pk, contratos_operacoes.pk
2. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.70..26,930.07 rows=1 width=2,311) (actual rows= loops=)

  • Join Filter: (contratos_operacoes.regra_negocio_nivel_codigo_agente_func = regra_negocio_nivel.codigo)
3. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.70..26,858.37 rows=1 width=1,735) (actual rows= loops=)

  • Join Filter: (contratos_operacoes.codigo_campanha_regional = campanhas_regional.codigo)
4. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.70..26,850.69 rows=1 width=1,711) (actual rows= loops=)

  • Join Filter: (contratos_operacoes.codigo_campanha_comercial = campanhas_comercial.codigo)
5. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.70..26,843.01 rows=1 width=1,687) (actual rows= loops=)

  • Join Filter: (contratos_operacoes.codigo_campanha_agente = campanhas_agente.codigo)
6. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.70..26,835.33 rows=1 width=1,663) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.28..26,831.73 rows=1 width=1,661) (actual rows= loops=)

  • Join Filter: (contratos_operacoes.codigo_operacoes_contrato = operacoes_contrato.codigo)
8. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.28..26,827.91 rows=1 width=1,657) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.86..26,824.44 rows=1 width=1,653) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Index Scan using contratos_operacoes_where_nao_list_pagos_ind on contratos_operacoes (cost=0.44..10,612.30 rows=3,962 width=627) (actual rows= loops=)

  • Filter: ((data_rec_comissao >= '2019-01-01'::date) AND (codigo_operacoes_contrato <> ALL ('{68,69,70}'::integer[])) AND (data_rec_comissao <= ('now'::cstring)::date))
11. 0.000 0.000 ↓ 0.0

Index Scan using contratos_comissoes_nova_materializada_view_unique on contratos_comissoes_materializada_view contratos (cost=0.43..4.08 rows=1 width=1,034) (actual rows= loops=)

  • Index Cond: (pk = contratos_operacoes.pk_contratos)
  • Filter: ((codigo_tipo_parceria = 2) AND (contratos_operacoes.codigo_instituicao = codigo_instituicao) AND (contratos_operacoes.codigo_loja = loja) AND (loja <> ALL ('{2745,2746,2747,2748}'::integer[]) (...)
12. 0.000 0.000 ↓ 0.0

Index Scan using controle_pagamento_valor_prem_codigo_contratos_operacoes_ti_key on controle_pagamento_valor_premio (cost=0.42..3.46 rows=1 width=8) (actual rows= loops=)

  • Index Cond: ((contratos_operacoes.pk = codigo_contratos_operacoes) AND ((tipo)::text = 'A'::text))
13. 0.000 0.000 ↓ 0.0

Seq Scan on operacoes_contrato (cost=0.00..2.81 rows=81 width=8) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Index Scan using receber_pkey on receber (cost=0.41..3.59 rows=1 width=6) (actual rows= loops=)

  • Index Cond: (contratos_operacoes.registro_contas_receber = codigo)
15. 0.000 0.000 ↓ 0.0

Seq Scan on campanhas campanhas_agente (cost=0.00..5.08 rows=208 width=28) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Seq Scan on campanhas campanhas_comercial (cost=0.00..5.08 rows=208 width=28) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Seq Scan on campanhas campanhas_regional (cost=0.00..5.08 rows=208 width=28) (actual rows= loops=)