explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2fjE

Settings
# exclusive inclusive rows x rows loops node
1. 0.191 9,138.648 ↑ 1.0 100 1

Limit (cost=0.58..318,733.40 rows=100 width=12) (actual time=12.092..9,138.648 rows=100 loops=1)

2. 1.783 9,138.457 ↑ 7.5 100 1

Nested Loop (cost=0.58..2,400,058.68 rows=753 width=12) (actual time=12.090..9,138.457 rows=100 loops=1)

3. 13.574 13.574 ↑ 7.5 100 1

Index Scan Backward using empresas_sucursales_nro_patronal_key on empresas_sucursales (cost=0.29..5,805.62 rows=753 width=44) (actual time=2.184..13.574 rows=100 loops=1)

  • Filter: ((type <> 1) AND (type <> 1))
  • Rows Removed by Filter: 670
4. 2.700 2.700 ↑ 1.0 1 100

Index Scan using empresas_pk on empresas emp (cost=0.29..2.31 rows=1 width=20) (actual time=0.024..0.027 rows=1 loops=100)

  • Index Cond: (id = empresas_sucursales.empresa_id)
  • Filter: (((document)::text <> '0'::text) AND ((document)::text <> ''::text) AND ((document)::text <> '-'::text))
5.          

SubPlan (forNested Loop)

6. 95.600 8,884.000 ↑ 1.0 1 100

Aggregate (cost=1,532.57..1,532.60 rows=1 width=16) (actual time=88.839..88.840 rows=1 loops=100)

7. 672.240 8,788.400 ↓ 11.1 820 100

Index Only Scan using empleados_empresa_id_id_idx on empleados emplea (cost=0.43..1,531.09 rows=74 width=16) (actual time=1.021..87.884 rows=820 loops=100)

  • Index Cond: (empresa_id = emp.id)
  • Filter: (SubPlan 2)
  • Rows Removed by Filter: 1209
  • Heap Fetches: 548
8.          

SubPlan (forIndex Only Scan)

9. 608.712 8,116.160 ↑ 1.0 1 202,904

Limit (cost=10.31..10.31 rows=1 width=20) (actual time=0.040..0.040 rows=1 loops=202,904)

10. 1,623.232 7,507.448 ↑ 1.0 1 202,904

Sort (cost=10.31..10.31 rows=1 width=20) (actual time=0.037..0.037 rows=1 loops=202,904)

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
11. 3,783.226 5,884.216 ↓ 2.0 2 202,904

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos (cost=0.43..10.30 rows=1 width=20) (actual time=0.019..0.029 rows=2 loops=202,904)

  • Index Cond: (empleado_id = emplea.id)
  • Filter: (NOT (SubPlan 1))
  • Rows Removed by Filter: 0
12.          

SubPlan (forIndex Scan)

13. 2,100.990 2,100.990 ↓ 0.0 0 350,165

Index Scan using multas_id_registro_multado_idx on multas (cost=0.00..4.02 rows=1 width=8) (actual time=0.006..0.006 rows=0 loops=350,165)

  • Index Cond: (id_registro_multado = empleados_movimientos.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
  • Rows Removed by Filter: 0
14. 1.300 236.400 ↑ 1.0 1 100

Aggregate (cost=1,644.69..1,644.70 rows=1 width=8) (actual time=2.364..2.364 rows=1 loops=100)

15. 2.700 235.100 ↑ 5.2 6 100

Nested Loop (cost=0.72..1,644.61 rows=31 width=8) (actual time=1.543..2.351 rows=6 loops=100)

16. 1.200 1.200 ↑ 1.0 1 100

Index Only Scan using empresas_sucursales_nro_patronal_key on empresas_sucursales es (cost=0.29..2.31 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=100)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
17. 4.840 231.200 ↑ 5.2 6 100

Nested Loop (cost=0.43..1,641.99 rows=31 width=16) (actual time=1.526..2.312 rows=6 loops=100)

18. 32.614 70.600 ↑ 6.7 9 100

Index Scan using empleados_npatronal_idx on empleados (cost=0.00..1,494.09 rows=60 width=24) (actual time=0.193..0.706 rows=9 loops=100)

  • Index Cond: (npatronal = empresas_sucursales.nro_patronal)
  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 1
19.          

SubPlan (forIndex Scan)

20. 3.896 37.986 ↑ 1.0 1 974

Limit (cost=10.31..10.31 rows=1 width=20) (actual time=0.038..0.039 rows=1 loops=974)

21. 7.792 34.090 ↑ 1.0 1 974

Sort (cost=10.31..10.31 rows=1 width=20) (actual time=0.035..0.035 rows=1 loops=974)

  • Sort Key: empleados_movimientos_1.fecha, empleados_movimientos_1.id
  • Sort Method: quicksort Memory: 25kB
22. 4.870 26.298 ↑ 1.0 1 974

Result (cost=0.43..10.30 rows=1 width=20) (actual time=0.020..0.027 rows=1 loops=974)

  • One-Time Filter: (empleados.empresa_id = emp.id)
23. 16.073 21.428 ↑ 1.0 1 974

Index Scan using empleados_movimientos_empleado_id_tipo_idx on empleados_movimientos empleados_movimientos_1 (cost=0.43..10.30 rows=1 width=20) (actual time=0.016..0.022 rows=1 loops=974)

  • Index Cond: (empleado_id = empleados.id)
  • Filter: (NOT (SubPlan 4))
24.          

SubPlan (forIndex Scan)

25. 5.355 5.355 ↓ 0.0 0 1,071

Index Scan using multas_id_registro_multado_idx on multas multas_1 (cost=0.00..4.02 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=1,071)

  • Index Cond: (id_registro_multado = empleados_movimientos_1.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))
26. 155.760 155.760 ↑ 1.0 1 880

Index Only Scan using persons_id_sexo_idx on persons (cost=0.43..2.46 rows=1 width=8) (actual time=0.175..0.177 rows=1 loops=880)

  • Index Cond: ((id = empleados.persona_id) AND (sexo = 'M'::text))
  • Heap Fetches: 12