Buen dia ahora me ha tocado lidiar con una tabla de fechas y horas

Tengo la consulta que muestro lineas mas abajo y luego el resultado del
explain analyze por favor alguna sugerencia para mejorar el tiempo de
respuesta

hasta el momento la tabla solo tiene estos dos indices que le agregue pero
solo he logrado dismunir el tiempo en 5 segundos la consulta tarda
aproximadamente 2 minutos

CREATE INDEX trans_dt ON trans (dt);
create index emp_fecha_hora on trans (empid,CAST (dt AS date),CAST(dt as
time));

SELECT m.empid AS dni, m.empname AS nombre_empleado, '201803' AS periodo,
m.fecha,
dia_semana(m.fecha) AS dia_semana, (
    SELECT min(m1.dt::time without time zone) AS min FROM trans m1
    WHERE m1.empid = m.empid AND m.fecha = m1.dt::date

    AND (m1.dt::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval
    AND (m1.dt::time without time zone - d.hora_ingreso) <=
d.hora_salida::interval AND
    m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin and d.turno_id = 1 or
d.turno_id = 3 and m1.dt::time without time zone < d.hora_salida
    GROUP BY (m1.dt::date)limit 1) AS hor_ing_ma,
    CASE WHEN ((( SELECT min(m1.dt::time without time zone) AS min FROM
trans m1
                WHERE m1.empid = m.empid AND m.fecha = m1.dt::date
                AND (m1.dt::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval
                AND (m1.dt::time without time zone - d.hora_salida) <=
'00'::interval
                AND m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin and
d.turno_id = 1
                or d.turno_id = 3 GROUP BY (m1.dt::date) limit 1)) -
d.hora_ingreso) >= '00:01:00'::time without time zone::interval
                THEN (( SELECT min(m1.dt::time without time zone) AS min
FROM trans m1
                    WHERE m1.empid = m.empid AND m.fecha = m1.dt::date
                    AND (m1.dt::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval
                    AND (m1.dt::time without time zone - d.hora_salida) <=
'00'::interval
                    AND m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin
                    and d.turno_id = 1 or d.turno_id = 3 GROUP BY
(m1.dt::date) limit 1)) - d.hora_ingreso ELSE NULL::interval END AS
tardanz_ma,
                    ( SELECT min(m1.dt::time without time zone) AS min FROM
trans m1
                    WHERE m1.empid = m.empid AND m.fecha = m1.dt::date
                    AND (m1.dt::time without time zone - d.hora_salida) >
'-00:59:00'::interval
                    AND (m1.dt::time without time zone - d.hora_salida) <=
d.sal_max_ma::interval
                    AND m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin
                    and d.turno_id = 1 or d.turno_id = 3 GROUP BY
(m1.dt::date) limit 1) AS hor_sal_ma,
                    CASE WHEN ((( SELECT min(m1.dt::time without time zone)
AS min FROM trans m1
                    WHERE m1.empid = m.empid AND m.fecha = m1.dt::date
                    AND (m1.dt::time without time zone - d.hora_salida) >
'-00:59:00'::interval
                    AND (m1.dt::time without time zone - d.hora_salida) <=
d.sal_max_ma::interval
                    AND m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin
                    and d.turno_id = 1 or d.turno_id = 3 GROUP BY
(m1.dt::date) limit 1 )) - d.hora_salida) >= '00:01:00'::time without time
zone::interval THEN (( SELECT min(m1.dt::time without time zone) AS min
FROM trans m1 WHERE m1.empid = m.empid AND m.fecha = m1.dt::date AND
(m1.dt::time without time zone - d.hora_salida) > '-00:59:00'::interval AND
(m1.dt::time without time zone - d.hora_salida) <= d.sal_max_ma::interval
AND m1.dt >= d.fecha_ini and m1.dt <= d.fecha_fin and d.turno_id = 1 or
d.turno_id = 3 GROUP BY (m1.dt::date) limit 1 )) - d.hora_salida ELSE
NULL::interval END AS tiem_compensar_ma, ( SELECT min(m1.dt::time without
time zone) AS min FROM trans m1 WHERE m1.empid = m.empid AND m.fecha =
m1.dt::date AND (m1.dt::time without time zone - d1.hora_ingreso) >
'-00:59:00'::interval AND (m1.dt::time without time zone - d1.hora_salida)
<= '00'::interval AND m1.dt >= d1.fecha_ini and m1.dt <= d1.fecha_fin and
d1.turno_id = 2 or d1.turno_id = 4 GROUP BY (m1.dt::date) limit 1 ) AS
hor_ing_ta, CASE WHEN ((( SELECT min(m1.dt::time without time zone) AS min
FROM trans m1 WHERE m1.empid = m.empid AND m.fecha = m1.dt::date AND
(m1.dt::time without time zone - d1.hora_ingreso) > '-00:59:00'::interval
AND (m1.dt::time without time zone - d1.hora_salida) <= '00'::interval AND
m1.dt >= d1.fecha_ini and m1.dt <= d1.fecha_fin and d1.turno_id = 2 or
d1.turno_id = 4 GROUP BY (m1.dt::date) limit 1)) - d1.hora_ingreso) >=
'00:01:00'::time without time zone::interval THEN (( SELECT min(m1.dt::time
without time zone) AS min FROM trans m1 WHERE m1.empid = m.empid AND
m.fecha = m1.dt::date AND (m1.dt::time without time zone - d1.hora_ingreso)
> '-00:59:00'::interval AND (m1.dt::time without time zone -
d1.hora_salida) <= '00'::interval AND m1.dt >= d1.fecha_ini and m1.dt <=
d1.fecha_fin and d1.turno_id = 2 or d1.turno_id = 4 GROUP BY (m1.dt::date)
limit 1 )) - d1.hora_ingreso ELSE NULL::interval END AS tardanz_ta, (
SELECT min(m1.dt::time without time zone) AS min FROM trans m1 WHERE
m1.empid = m.empid AND m.fecha = m1.dt::date AND (m1.dt::time without time
zone - d1.hora_salida) > '-00:59:00'::interval AND (m1.dt::time without
time zone - d1.hora_salida) <= d1.sal_max_ta::interval AND m1.dt >=
d1.fecha_ini and m1.dt <= d1.fecha_fin and d1.turno_id = 2 or d1.turno_id =
4 GROUP BY (m1.dt::date) limit 1 ) AS hor_sal_ta, CASE WHEN ((( SELECT
min(m1.dt::time without time zone) AS min FROM trans m1 WHERE m1.empid =
m.empid AND m.fecha = m1.dt::date AND (m1.dt::time without time zone -
d1.hora_salida) > '-00:59:00'::interval AND (m1.dt::time without time zone
- d1.hora_salida) <= d1.sal_max_ta::interval AND m1.dt >= d1.fecha_ini and
m1.dt <= d1.fecha_fin and d1.turno_id = 2 or d1.turno_id = 4 GROUP BY
(m1.dt::date))) - d1.hora_salida) >= '00:01:00'::time without time
zone::interval
                    THEN (( SELECT min(m1.dt::time without time zone) AS
min FROM trans m1
                    WHERE m1.empid = m.empid AND m.fecha = m1.dt::date
                        AND (m1.dt::time without time zone -
d1.hora_salida) > '-00:59:00'::interval
                        AND (m1.dt::time without time zone -
d1.hora_salida) <= d1.sal_max_ta::interval
                        AND m1.dt >= d1.fecha_ini and m1.dt <= d1.fecha_fin
                        and d1.turno_id = 2 or d1.turno_id = 4 GROUP BY
(m1.dt::date) limit 1 )) - d1.hora_salida ELSE NULL::interval END AS
tiem_compensar_ta FROM trans m LEFT JOIN rrhh_persona_horario d on m.empid
= d.documento and d.activo = 1 and d.turno_id = 1 or d.turno_id = 3 LEFT
JOIN rrhh_persona_horario d1 on m.empid = d1.documento and d1.activo = 1
and d1.turno_id = 2 or d1.turno_id = 4 WHERE ((m.dt >= d.fecha_ini and m.dt
<= d.fecha_fin ) or (m.dt >= d1.fecha_ini and m.dt <= d1.fecha_fin )) and
(m.dt >= '20180226' and m.dt <= '20180307')
    GROUP BY m.empid, m.empname, m.fecha,
d.fecha_ini,d.fecha_fin,d.hora_ingreso,d.hora_salida,d.turno_id,d.sal_max_ma,d.sal_max_ta,
d1.fecha_ini,d1.fecha_fin,d1.hora_ingreso,d1.hora_salida,d1.turno_id,d1.sal_max_ma,d1.sal_max_ta
ORDER BY m.fecha;


"Group  (cost=7474.69..3976090.10 rows=337 width=263) (actual
time=232.781..109954.357 rows=2007 loops=1)"
"  Group Key: m.fecha, m.empid, m.empname, d.fecha_ini, d.fecha_fin,
d.hora_ingreso, d.hora_salida, d.turno_id, d.sal_max_ma, d.sal_max_ta,
d1.fecha_ini, d1.fecha_fin, d1.hora_ingreso, d1.hora_salida,
d1.turno_id, d1.sal_max_ma, d1.sal_max_ta"
"  ->  Sort  (cost=7474.69..7475.54 rows=337 width=103) (actual
time=182.457..183.850 rows=5575 loops=1)"
"        Sort Key: m.fecha, m.empid, m.empname, d.fecha_ini,
d.fecha_fin, d.hora_ingreso, d.hora_salida, d.turno_id, d.sal_max_ma,
d.sal_max_ta, d1.fecha_ini, d1.fecha_fin, d1.hora_ingreso,
d1.hora_salida, d1.turno_id, d1.sal_max_ma, d1.sal_max_ta"
"        Sort Method: quicksort  Memory: 887kB"
"        ->  Nested Loop Left Join  (cost=0.29..7460.55 rows=337
width=103) (actual time=0.572..139.117 rows=5575 loops=1)"
"              Join Filter: (((m.empid = (d.documento)::text) AND
(d.activo = 1) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"              Rows Removed by Join Filter: 260627"
"              Filter: (((m.dt >= d.fecha_ini) AND (m.dt <=
d.fecha_fin)) OR ((m.dt >= d1.fecha_ini) AND (m.dt <= d1.fecha_fin)))"
"              Rows Removed by Filter: 6050"
"              ->  Nested Loop Left Join  (cost=0.29..2908.81
rows=1319 width=73) (actual time=0.201..46.688 rows=2347 loops=1)"
"                    Join Filter: (((m.empid = (d1.documento)::text)
AND (d1.activo = 1) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                    Rows Removed by Join Filter: 134955"
"                    ->  Index Scan using trans_dt on trans m
(cost=0.29..135.13 rows=1294 width=35) (actual time=0.034..1.049
rows=1383 loops=1)"
"                          Index Cond: ((dt >= '2018-02-26
00:00:00'::timestamp without time zone) AND (dt <= '2018-03-07
00:00:00'::timestamp without time zone))"
"                    ->  Materialize  (cost=0.00..7.99 rows=95
width=49) (actual time=0.000..0.006 rows=99 loops=1383)"
"                          ->  Seq Scan on rrhh_persona_horario d1
(cost=0.00..7.52 rows=95 width=49) (actual time=0.017..0.106 rows=99
loops=1)"
"                                Filter: (((activo = 1) AND (turno_id
= 2)) OR (turno_id = 4))"
"                                Rows Removed by Filter: 116"
"              ->  Materialize  (cost=0.00..8.05 rows=106 width=49)
(actual time=0.000..0.007 rows=116 loops=2347)"
"                    ->  Seq Scan on rrhh_persona_horario d
(cost=0.00..7.52 rows=106 width=49) (actual time=0.008..0.096 rows=116
loops=1)"
"                          Filter: (((activo = 1) AND (turno_id = 1))
OR (turno_id = 3))"
"                          Rows Removed by Filter: 99"
"  SubPlan 1"
"    ->  Limit  (cost=976.07..976.09 rows=1 width=12) (actual
time=2.607..2.607 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=976.07..976.61 rows=24 width=12)
(actual time=2.605..2.605 rows=1 loops=2007)"
"                Group Key: ((m1.dt)::date)"
"                ->  Sort  (cost=976.07..976.13 rows=24 width=12)
(actual time=2.595..2.595 rows=3 loops=2007)"
"                      Sort Key: ((m1.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Bitmap Heap Scan on trans m1
(cost=414.41..975.52 rows=24 width=12) (actual time=2.314..2.547
rows=96 loops=2007)"
"                            Recheck Cond: (((empid = m.empid) AND
(m.fecha = (dt)::date)) OR ((dt)::time without time zone <
d.hora_salida))"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_ingreso) <= (d.hora_salida)::interval) AND (dt >= d.fecha_ini)
AND (dt <= d.fecha_fin) AND (d.turno_id = 1)) OR ((d.turno_id = 3) AND
((dt)::time without time zone < d.hora_salida)))"
"                            Rows Removed by Filter: 2658"
"                            Heap Blocks: exact=264670"
"                            ->  BitmapOr  (cost=414.41..414.41
rows=4881 width=0) (actual time=1.250..1.250 rows=0 loops=2007)"
"                                  ->  Bitmap Index Scan on
emp_fecha_hora  (cost=0.00..4.29 rows=1 width=0) (actual
time=0.033..0.033 rows=3 loops=2007)"
"                                        Index Cond: ((empid =
m.empid) AND (m.fecha = (dt)::date))"
"                                  ->  Bitmap Index Scan on
emp_fecha_hora  (cost=0.00..410.10 rows=4881 width=0) (actual
time=1.210..1.210 rows=2752 loops=2007)"
"                                        Index Cond: ((dt)::time
without time zone < d.hora_salida)"
"  SubPlan 2"
"    ->  Limit  (cost=941.73..941.75 rows=1 width=12) (actual
time=9.182..9.182 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=941.73..943.37 rows=73 width=12)
(actual time=9.179..9.179 rows=1 loops=2007)"
"                Group Key: ((m1_1.dt)::date)"
"                ->  Sort  (cost=941.73..941.91 rows=73 width=12)
(actual time=9.057..9.064 rows=125 loops=2007)"
"                      Sort Key: ((m1_1.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_1  (cost=0.00..939.47
rows=73 width=12) (actual time=1.832..7.138 rows=8842 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_salida) <= '00:00:00'::interval) AND (dt >= d.fecha_ini) AND
(dt <= d.fecha_fin) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"                            Rows Removed by Filter: 5800"
"  SubPlan 3"
"    ->  Limit  (cost=941.73..941.75 rows=1 width=12) (actual
time=5.200..5.201 rows=1 loops=161)"
"          ->  GroupAggregate  (cost=941.73..943.37 rows=73 width=12)
(actual time=5.198..5.198 rows=1 loops=161)"
"                Group Key: ((m1_2.dt)::date)"
"                ->  Sort  (cost=941.73..941.91 rows=73 width=12)
(actual time=5.187..5.187 rows=1 loops=161)"
"                      Sort Key: ((m1_2.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_2  (cost=0.00..939.47
rows=73 width=12) (actual time=4.603..5.164 rows=1 loops=161)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_salida) <= '00:00:00'::interval) AND (dt >= d.fecha_ini) AND
(dt <= d.fecha_fin) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"                            Rows Removed by Filter: 14641"
"  SubPlan 4"
"    ->  Limit  (cost=1014.94..1014.96 rows=1 width=12) (actual
time=9.184..9.185 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=1014.94..1016.58 rows=73
width=12) (actual time=9.182..9.182 rows=1 loops=2007)"
"                Group Key: ((m1_3.dt)::date)"
"                ->  Sort  (cost=1014.94..1015.12 rows=73 width=12)
(actual time=9.041..9.049 rows=125 loops=2007)"
"                      Sort Key: ((m1_3.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_3  (cost=0.00..1012.68
rows=73 width=12) (actual time=1.810..7.104 rows=8843 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_salida) <= (d.sal_max_ma)::interval) AND (dt >= d.fecha_ini)
AND (dt <= d.fecha_fin) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"                            Rows Removed by Filter: 5799"
"  SubPlan 5"
"    ->  Limit  (cost=1014.94..1014.96 rows=1 width=12) (actual
time=9.253..9.254 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=1014.94..1016.58 rows=73
width=12) (actual time=9.251..9.251 rows=1 loops=2007)"
"                Group Key: ((m1_4.dt)::date)"
"                ->  Sort  (cost=1014.94..1015.12 rows=73 width=12)
(actual time=9.073..9.080 rows=125 loops=2007)"
"                      Sort Key: ((m1_4.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_4  (cost=0.00..1012.68
rows=73 width=12) (actual time=1.803..7.108 rows=8843 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_salida) <= (d.sal_max_ma)::interval) AND (dt >= d.fecha_ini)
AND (dt <= d.fecha_fin) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"                            Rows Removed by Filter: 5799"
"  SubPlan 6"
"    ->  Limit  (cost=1014.94..1014.96 rows=1 width=12) (actual
time=4.896..4.896 rows=1 loops=515)"
"          ->  GroupAggregate  (cost=1014.94..1016.58 rows=73
width=12) (actual time=4.894..4.894 rows=1 loops=515)"
"                Group Key: ((m1_5.dt)::date)"
"                ->  Sort  (cost=1014.94..1015.12 rows=73 width=12)
(actual time=4.884..4.885 rows=2 loops=515)"
"                      Sort Key: ((m1_5.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_5  (cost=0.00..1012.68
rows=73 width=12) (actual time=4.331..4.865 rows=2 loops=515)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d.hora_salida) <= (d.sal_max_ma)::interval) AND (dt >= d.fecha_ini)
AND (dt <= d.fecha_fin) AND (d.turno_id = 1)) OR (d.turno_id = 3))"
"                            Rows Removed by Filter: 14640"
"  SubPlan 7"
"    ->  Limit  (cost=941.73..941.75 rows=1 width=12) (actual
time=4.933..4.933 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=941.73..943.37 rows=73 width=12)
(actual time=4.931..4.931 rows=1 loops=2007)"
"                Group Key: ((m1_6.dt)::date)"
"                ->  Sort  (cost=941.73..941.91 rows=73 width=12)
(actual time=4.923..4.923 rows=1 loops=2007)"
"                      Sort Key: ((m1_6.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_6  (cost=0.00..939.47
rows=73 width=12) (actual time=4.563..4.901 rows=1 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d1.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= '00:00:00'::interval) AND (dt >= d1.fecha_ini) AND
(dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                            Rows Removed by Filter: 14641"
"  SubPlan 8"
"    ->  Limit  (cost=941.73..941.75 rows=1 width=12) (actual
time=4.899..4.899 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=941.73..943.37 rows=73 width=12)
(actual time=4.897..4.897 rows=1 loops=2007)"
"                Group Key: ((m1_7.dt)::date)"
"                ->  Sort  (cost=941.73..941.91 rows=73 width=12)
(actual time=4.890..4.890 rows=1 loops=2007)"
"                      Sort Key: ((m1_7.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_7  (cost=0.00..939.47
rows=73 width=12) (actual time=4.532..4.870 rows=1 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d1.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= '00:00:00'::interval) AND (dt >= d1.fecha_ini) AND
(dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                            Rows Removed by Filter: 14641"
"  SubPlan 9"
"    ->  Limit  (cost=941.73..941.75 rows=1 width=12) (actual
time=4.911..4.912 rows=1 loops=367)"
"          ->  GroupAggregate  (cost=941.73..943.37 rows=73 width=12)
(actual time=4.909..4.909 rows=1 loops=367)"
"                Group Key: ((m1_8.dt)::date)"
"                ->  Sort  (cost=941.73..941.91 rows=73 width=12)
(actual time=4.900..4.900 rows=1 loops=367)"
"                      Sort Key: ((m1_8.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_8  (cost=0.00..939.47
rows=73 width=12) (actual time=4.235..4.880 rows=1 loops=367)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d1.hora_ingreso) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= '00:00:00'::interval) AND (dt >= d1.fecha_ini) AND
(dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                            Rows Removed by Filter: 14641"
"  SubPlan 10"
"    ->  Limit  (cost=1014.94..1014.96 rows=1 width=12) (actual
time=5.028..5.028 rows=1 loops=2007)"
"          ->  GroupAggregate  (cost=1014.94..1016.58 rows=73
width=12) (actual time=5.026..5.026 rows=1 loops=2007)"
"                Group Key: ((m1_9.dt)::date)"
"                ->  Sort  (cost=1014.94..1015.12 rows=73 width=12)
(actual time=5.019..5.019 rows=1 loops=2007)"
"                      Sort Key: ((m1_9.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_9  (cost=0.00..1012.68
rows=73 width=12) (actual time=4.646..4.999 rows=1 loops=2007)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d1.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= (d1.sal_max_ta)::interval) AND (dt >= d1.fecha_ini)
AND (dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                            Rows Removed by Filter: 14641"
"  SubPlan 11"
"    ->  GroupAggregate  (cost=1014.94..1016.58 rows=73 width=12)
(actual time=4.923..4.923 rows=1 loops=2007)"
"          Group Key: ((m1_10.dt)::date)"
"          ->  Sort  (cost=1014.94..1015.12 rows=73 width=12) (actual
time=4.916..4.916 rows=1 loops=2007)"
"                Sort Key: ((m1_10.dt)::date)"
"                Sort Method: quicksort  Memory: 17kB"
"                ->  Seq Scan on trans m1_10  (cost=0.00..1012.68
rows=73 width=12) (actual time=4.555..4.898 rows=1 loops=2007)"
"                      Filter: (((empid = m.empid) AND (m.fecha =
(dt)::date) AND (((dt)::time without time zone - d1.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= (d1.sal_max_ta)::interval) AND (dt >= d1.fecha_ini)
AND (dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                      Rows Removed by Filter: 14641"
"  SubPlan 12"
"    ->  Limit  (cost=1014.94..1014.96 rows=1 width=12) (actual
time=4.901..4.901 rows=1 loops=836)"
"          ->  GroupAggregate  (cost=1014.94..1016.58 rows=73
width=12) (actual time=4.899..4.899 rows=1 loops=836)"
"                Group Key: ((m1_11.dt)::date)"
"                ->  Sort  (cost=1014.94..1015.12 rows=73 width=12)
(actual time=4.890..4.890 rows=1 loops=836)"
"                      Sort Key: ((m1_11.dt)::date)"
"                      Sort Method: quicksort  Memory: 17kB"
"                      ->  Seq Scan on trans m1_11
(cost=0.00..1012.68 rows=73 width=12) (actual time=4.241..4.870 rows=1
loops=836)"
"                            Filter: (((empid = m.empid) AND (m.fecha
= (dt)::date) AND (((dt)::time without time zone - d1.hora_salida) >
'-00:59:00'::interval) AND (((dt)::time without time zone -
d1.hora_salida) <= (d1.sal_max_ta)::interval) AND (dt >= d1.fecha_ini)
AND (dt <= d1.fecha_fin) AND (d1.turno_id = 2)) OR (d1.turno_id = 4))"
"                            Rows Removed by Filter: 14641"
"Planning time: 2.927 ms"
"Execution time: 109957.969 ms"



-- 
José Mercedes Venegas Acevedo
cel Mov RPC 964185205

Reply via email to