pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Reiner Dassing <dassing@wettzell.ifag.de>
To: pgsql-performance@postgresql.org
Subject: Re: Select on timestamp-day slower than timestamp alone
Date: Tue, 6 May 2003 14:04:24 +0100
Message-ID: <200305061404.24194.dev@archonet.com> (raw)
In-Reply-To: <3EB75D5F.5080406@wettzell.ifag.de>
References: <3EB75D5F.5080406@wettzell.ifag.de>

On Tuesday 06 May 2003 7:59 am, Reiner Dassing wrote:
> Hello all!
>
> On PostgreSQL V7.3.2 on TRU64 I recognized the following phenomena
> that a SELECT using a difference of a timestamp and an interval
> in the WHERE clause does not use the index
> but using a timestamp without a difference does use the index.
> The semantic of both SELECT's is equal, i.e., the result is equal.
>
> Therefore, the second way is much faster.
>
> Any ideas?

> Select not using index:
> -----------------------
> wetter=# explain select * from wetter where epoche between
> '2003-05-06 06:50:54+00'::timestamp-'1 days'::interval
> AND '2003-05-06 04:45:36';
>
>           QUERY PLAN
>
> ---------------------------------------------------------------------------
>----------------------------------------------------------------------------
>-------------------- Seq Scan on wetter  (cost=0.00..768644.57 rows=10253528
> width=16) Filter: ((epoche >= ('2003-05-05 06:50:54'::timestamp without
> time zone)::timestamp with time zone) AND (epoche <= '2003-05-06
> 04:45:36+00'::timestamp with time zone))
> (2 rows)

Well, the "why" is because the number of rows recommended is so big 
(rows=10253528) - I'm also puzzled why we get "timestamp without time zone". 
Does an explicit cast to "with time zone" help?

-- 
  Richard Huxton




view thread (4+ messages)  latest in thread

Message-ID: <200305061404.24194.dev@archonet.com>
Permalink:  ../200305061404.24194.dev@archonet.com/
Also on:    postgresql.org/message-id/200305061404.24194.dev@archonet.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, dassing@wettzell.ifag.de
  Subject: Re: Select on timestamp-day slower than timestamp alone
  In-Reply-To: <200305061404.24194.dev@archonet.com>
  References: <3EB75D5F.5080406@wettzell.ifag.de> <200305061404.24194.dev@archonet.com>

* 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