explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EiX7

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

Sort (cost=852.50..857.04 rows=1,814 width=387) (actual rows= loops=)

  • Sort Key: a.id_empresa
2.          

CTE params

3. 0.000 0.000 ↓ 0.0

CTE Scan on a a_1 (cost=0.01..0.04 rows=1 width=36) (actual rows= loops=)

4.          

CTE a

5. 0.000 0.000 ↓ 0.0

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

6.          

CTE regimes

7. 0.000 0.000 ↓ 0.0

HashAggregate (cost=35.25..44.83 rows=958 width=12) (actual rows= loops=)

  • Group Key: a_2.id_empresa
8. 0.000 0.000 ↓ 0.0

Seq Scan on cad_regimes_federais a_2 (cost=0.00..29.50 rows=1,150 width=12) (actual rows= loops=)

9.          

CTE enderecos

10. 0.000 0.000 ↓ 0.0

HashAggregate (cost=19.94..29.20 rows=926 width=16) (actual rows= loops=)

  • Group Key: a_3.id_empresa
11. 0.000 0.000 ↓ 0.0

Seq Scan on cad_empresas_has_endereco a_3 (cost=0.00..15.29 rows=929 width=16) (actual rows= loops=)

12.          

Initplan (for Sort)

13. 0.000 0.000 ↓ 0.0

CTE Scan on params (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

CTE Scan on params params_1 (cost=0.00..0.02 rows=1 width=32) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=645.52..680.22 rows=1,814 width=387) (actual rows= loops=)

  • Merge Cond: (((a.id_empresa)::bigint) = g.id_empresa)
16. 0.000 0.000 ↓ 0.0

Sort (cost=581.37..582.35 rows=392 width=379) (actual rows= loops=)

  • Sort Key: ((a.id_empresa)::bigint)
17. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=506.54..564.48 rows=392 width=379) (actual rows= loops=)

  • Hash Cond: (a.tipo = e.tipo)
18. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=504.39..556.94 rows=392 width=359) (actual rows= loops=)

  • Hash Cond: ((a.cnae)::text = (d.cnae)::text)
19. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=434.21..481.37 rows=392 width=304) (actual rows= loops=)

  • Hash Cond: (a.codg_municipio = c.codg_municipio)
20. 0.000 0.000 ↓ 0.0

Hash Join (cost=239.82..281.71 rows=392 width=292) (actual rows= loops=)

  • Hash Cond: (f.id_empresa = a.id_empresa)
21. 0.000 0.000 ↓ 0.0

Index Only Scan using cad_usuarios_empresas_pkey on cad_usuarios_empresas f (cost=0.29..34.38 rows=1,034 width=4) (actual rows= loops=)

  • Index Cond: (id_usuario = 3)
22. 0.000 0.000 ↓ 0.0

Hash (cost=234.55..234.55 rows=398 width=292) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=196.40..234.55 rows=398 width=292) (actual rows= loops=)

  • Hash Cond: ((h.id_empresa = a.id_empresa) AND (h.vigencia2 = b.vigencia2))
  • Filter: CASE WHEN (($4 > 0) AND (h.id_regime IS NOT NULL)) THEN (h.id_tipo_regime = ANY ($5)) ELSE true END
24. 0.000 0.000 ↓ 0.0

Seq Scan on cad_regimes_federais h (cost=0.00..29.50 rows=1,150 width=20) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Hash (cost=184.46..184.46 rows=796 width=292) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=154.45..184.46 rows=796 width=292) (actual rows= loops=)

  • Hash Cond: (b.id_empresa = a.id_empresa)
27. 0.000 0.000 ↓ 0.0

CTE Scan on regimes b (cost=0.00..19.16 rows=958 width=12) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Hash (cost=144.50..144.50 rows=796 width=288) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Seq Scan on cad_empresas a (cost=0.00..144.50 rows=796 width=288) (actual rows= loops=)

  • Filter: ((ativo = 1) AND (analise = ANY (('{0," 1"}'::text[])::boolean[])))
30. 0.000 0.000 ↓ 0.0

Hash (cost=124.73..124.73 rows=5,573 width=16) (actual rows= loops=)

31. 0.000 0.000 ↓ 0.0

Seq Scan on cad_estados_municipios c (cost=0.00..124.73 rows=5,573 width=16) (actual rows= loops=)

32. 0.000 0.000 ↓ 0.0

Hash (cost=48.97..48.97 rows=1,697 width=62) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Seq Scan on cad_cnaes_fiscais d (cost=0.00..48.97 rows=1,697 width=62) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Hash (cost=1.51..1.51 rows=51 width=24) (actual rows= loops=)

35. 0.000 0.000 ↓ 0.0

Seq Scan on cad_empresas_tipos e (cost=0.00..1.51 rows=51 width=24) (actual rows= loops=)

36. 0.000 0.000 ↓ 0.0

Sort (cost=64.15..66.46 rows=926 width=16) (actual rows= loops=)

  • Sort Key: g.id_empresa
37. 0.000 0.000 ↓ 0.0

CTE Scan on enderecos g (cost=0.00..18.52 rows=926 width=16) (actual rows= loops=)