Timestamps and performances problems - Mailing list pgsql-admin

From Jean-Christophe ARNU (JX)
Subject Timestamps and performances problems
Date
Msg-id 20020410042215.38c9f863.arnu@paratronic.fr
Whole thread Raw
List pgsql-admin
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
> Notre devoir, pour leur bien et pour le bien de Linux, est de te
> flinguer avant que tu ne les sacrifies (fût-ce avec les meilleures
> intentions du monde).
-+- TP In: Guide du linuxien pervers : "De la pédagogie par l'Exemple"

pgsql-admin by date:

Previous
From: Jean-Christophe ARNU (JX)
Date:
Subject: Timestamps and performance problems on queries.
Next
From: Tariq Muhammad
Date:
Subject: Please help