Timestamps and performance problems on queries.

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 ?" -+-

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
jc.arnu [ Mi, 10 April 2002 10:12 ] [ ID #7327 ]

Re:

--_a822e7d6-6126-4e4c-994d-594a3a620136_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


my happiness!
I found a large-scale sales compan-- Kimsell.There are favourable price and=
fine quality goods very much.When I ordered the Dell computer=2Cin one wee=
k=2CI received it and found it very well in the quality.I am very happy for=
the purching.I hope that you can share my happiness.
www.ynchenxi.com
You can find what you want to.
Greetings!

____________________________________________________________ _____
Browse profiles for FREE! Meet local singles online.
http://clk.atdmt.com/NMN/go/150855801/direct/01/=

--_a822e7d6-6126-4e4c-994d-594a3a620136_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
..hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Verdana
}
--></style>
</head>
<body class=3D'hmmessage'>
my happiness!<BR>I found a large-scale sales compan-- Kimsell.There are fav=
ourable price and fine quality goods very much.When I ordered the Dell comp=
uter=2Cin one week=2CI received it and found it very well in the quality.I =
am very happy for the purching.I hope that you can share my happiness.<BR>&=
nbsp=3B www.ynchenxi.com<BR>You can find what you want to.<BR>Greetings!<BR=
>
<hr />Meet local singles online. <a href=3D'http://clk.a=
tdmt.com/NMN/go/150855801/direct/01/' target=3D'_new'>Browse profiles for F=
REE!</a></body>
</html>=

--_a822e7d6-6126-4e4c-994d-594a3a620136_--
Verna Violet [ Mi, 21 April 2010 02:26 ] [ ID #2039649 ]
Datenbanken » gmane.comp.db.postgresql.admin » Timestamps and performance problems on queries.

Vorheriges Thema: pg_restore -j
Nächstes Thema: Can the log_statement parameter be set at the user level?