"mdc@keko.com.ar" <mdc@keko.com.ar> writes:
> numeroVia | smallint | not null
> fechaHora | timestamp(3) with time zone | not null
> explain delete from "Transitos"
> where "codigoEstacion"= '02' and
> "numeroVia" = 1 and
> "fechaHora" = '2003-0403 17:34:06.92'::timestamp and
> "medioPago" = 'Efectivo' and
> "tipoTransito"= 'Normal' and
> categoria='01'
You're casting the constant compared to fechaHora to timestamp, which is
the wrong thing (timestamp != timestamp with timezone); and you're not
casting the constant compared to numeroVia to smallint. Each of these
type mismatches will prevent an indexscan.
If I were you I'd declare numeroVia as int, not smallint, because you're
getting no space savings from smallint anyway. Then you could just
write
delete from "Transitos"
where "codigoEstacion"= '02' and
"numeroVia" = 1 and
"fechaHora" = '2003-0403 17:34:06.92' and
"medioPago" = 'Efectivo' and
"tipoTransito"= 'Normal' and
categoria='01'
and it should do what you want.
regards, tom lane