X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4532147580B for ; Mon, 14 Apr 2003 19:34:08 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8D797474E44 for ; Mon, 14 Apr 2003 19:34:07 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3ENYjU6002620; Mon, 14 Apr 2003 19:34:45 -0400 (EDT) To: "mdc@keko.com.ar" Cc: pgsql-sql@postgresql.org Subject: Re: help with query!!! In-reply-to: <3e9b3112.22ad.16838@keko.com.ar> References: <3e9b3112.22ad.16838@keko.com.ar> Comments: In-reply-to "mdc@keko.com.ar" message dated "Mon, 14 Apr 2003 19:07:14 -0300" Date: Mon, 14 Apr 2003 19:34:45 -0400 Message-ID: <2619.1050363285@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-27.0 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,PLING_PLING, REFERENCES,REPLY_WITH_QUOTES,TO_ADDRESS_EQ_REAL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/214 X-Sequence-Number: 12915 "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