pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Christophe ARNU (JX) <jc.arnu@wanadoo.fr>
To: pgsql-admin@postgresql.org
Subject: Timestamps and performance problems on queries.
Date: Wed, 10 Apr 2002 04:12:58 -0400
Message-ID: <20020410041258.345a35ec.jc.arnu@wanadoo.fr> (raw)

Hello all.
I've a performance problem on specific requests :

When I use timestamps + interval in where clauses, query performance is slowed
down by a factor of 20 or 30!!!! For exemple : 
	select timestamp,value 
	from measure 
	where timestamp<now() and timestamp>(now() - '1 hour'::interval) 

	is 20 to 30 times longer than 

	select timestamp,value 
	from measure 
	where timestamp<'2002-04-10 10:00' and timestamp>='2002-04-10 9:00'; 

So where is the bottleneck?
A paradigm seems that now() and (now() - '1hour'::interval) is evaluated for
each row comparison... Am I right? Thus is there a way to make SQL interpreter
evaluate this by rewriting them before launching any comparisons?

Or do I have to rewrite all my application queries and calculate each time
now() and interval predicates?

	Thanks by advance

-- 
Jean-Christophe ARNU
s/w developer 
Paratronic France
> (Pas Adabase que j'ai en version démo sur la distribution Suze).
Et après ça, allez expliquer que les linuxiens sont pas alcolos... ;-)
à quand une distribution Kro v1.6.64 ou Pastis v5.1?
-+-  Fantec In Guide du linuxien pervers - "C'est l'heure de l'apéro ?" -+-



Message-ID: <20020410041258.345a35ec.jc.arnu@wanadoo.fr>
Permalink:  ../20020410041258.345a35ec.jc.arnu@wanadoo.fr/
Also on:    postgresql.org/message-id/20020410041258.345a35ec.jc.arnu@wanadoo.fr

 · 

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-admin@postgresql.org
  Cc: jc.arnu@wanadoo.fr
  Subject: Re: Timestamps and performance problems on queries.
  In-Reply-To: <20020410041258.345a35ec.jc.arnu@wanadoo.fr>
  References: <20020410041258.345a35ec.jc.arnu@wanadoo.fr>

* 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