pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: mdc@keko.com.ar <mdc@keko.com.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: help with query!!!
Date: Mon, 14 Apr 2003 19:34:45 -0400
Message-ID: <2619.1050363285@sss.pgh.pa.us> (raw)
In-Reply-To: <3e9b3112.22ad.16838@keko.com.ar>
References: <3e9b3112.22ad.16838@keko.com.ar>

"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




view thread (15+ messages)  latest in thread

Message-ID: <2619.1050363285@sss.pgh.pa.us>
Permalink:  ../2619.1050363285@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2619.1050363285@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mdc@keko.com.ar
  Subject: Re: help with query!!!
  In-Reply-To: <2619.1050363285@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox