explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2q6R

Settings
# exclusive inclusive rows x rows loops node
1. 0.156 53.677 ↑ 1.0 100 1

Limit (cost=0.58..150,719.26 rows=100 width=12) (actual time=0.161..53.677 rows=100 loops=1)

2. 0.667 53.521 ↑ 7.5 100 1

Nested Loop (cost=0.58..1,134,912.23 rows=753 width=12) (actual time=0.159..53.521 rows=100 loops=1)

3. 2.954 2.954 ↑ 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=0.068..2.954 rows=100 loops=1)

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

Index Scan using empresas_pk on empresas emp (cost=0.29..2.31 rows=1 width=20) (actual time=0.014..0.015 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. 1.300 48.400 ↑ 1.0 1 100

Aggregate (cost=1,497.15..1,497.16 rows=1 width=8) (actual time=0.483..0.484 rows=1 loops=100)

7. 1.900 47.100 ↑ 6.7 9 100

Nested Loop (cost=0.29..1,497.00 rows=60 width=8) (actual time=0.060..0.471 rows=9 loops=100)

8. 0.600 0.600 ↑ 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.004..0.006 rows=1 loops=100)

  • Index Cond: (nro_patronal = empresas_sucursales.nro_patronal)
  • Heap Fetches: 0
9. 9.536 44.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.050..0.446 rows=9 loops=100)

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

SubPlan (forIndex Scan)

11. 1.948 35.064 ↑ 1.0 1 974

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

12. 6.818 33.116 ↑ 1.0 1 974

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

  • Sort Key: empleados_movimientos.fecha, empleados_movimientos.id
  • Sort Method: quicksort Memory: 25kB
13. 3.896 26.298 ↑ 1.0 1 974

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

  • One-Time Filter: (empleados.empresa_id = emp.id)
14. 17.047 22.402 ↑ 1.0 1 974

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

  • Index Cond: (empleado_id = empleados.id)
  • Filter: (NOT (SubPlan 1))
15.          

SubPlan (forIndex Scan)

16. 5.355 5.355 ↓ 0.0 0 1,071

Index Scan using multas_id_registro_multado_idx on multas (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.id)
  • Filter: ((estado IS NULL) AND (idtipo_multa = 11))