Received: from bast.unixathome.org (bast.unixathome.org [216.187.105.150]) by postgresql.org (Postfix) with ESMTP id 10B76475852 for ; Wed, 10 Apr 2002 10:55:19 -0400 (EDT) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id 75C093F30; Wed, 10 Apr 2002 10:56:11 -0400 (EDT) From: "Dan Langille" Organization: DVL Software Limited To: Jean-Christophe ARNU (JX) Date: Wed, 10 Apr 2002 10:55:22 -0400 MIME-Version: 1.0 Subject: Re: Timestamps and performances problems Reply-To: dan@langille.org Cc: pgsql-admin@postgresql.org In-reply-to: <20020410104425.59ce6791.jc.arnu@free.fr> References: <20020410132758.F37F23F30@bast.unixathome.org> X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Message-Id: <20020410145611.75C093F30@bast.unixathome.org> X-Archive-Number: 200204/83 X-Sequence-Number: 3971 On 10 Apr 2002 at 10:44, JX wrote: > Le Wed, 10 Apr 2002 09:27:09 -0400 > "Dan Langille" me disait que : > > > On 10 Apr 2002 at 9:13, JX wrote: > > > > > Le Wed, 10 Apr 2002 09:06:55 -0400 > > > "Dan Langille" me disait que : > > > > > > > On 10 Apr 2002 at 11:51, Gaetano Mendola wrote: > > > > > > > > > "Jean-Christophe ARNU (JX)" wrote: > > > > > > 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() - '1 hour'::interval) > > > > > > > > Try where timestamp(now() - '1 > > > > hour'::interval)::timestemp. > > > > > > What's the difference with the syntax above? It takes he same time > > > than the query above. Bounded timestamps with "real" ISO timestamps > > > strings are always up to about 200 times faster (with extensive test > > > proof). > > > > It casts the value to a timestamp. I would prefer to discuss this on- > > list. > Okaye, but what's the incidence on preformance issues? > Casting should only insure that given string is to be taken as a timestamp > isn't it? Does it make an "instanciation" of the timestamp to be that would be > applied for comparision clauses? If there is an index on that field, casting to a timestamp may help the optimization. Therefore I suggested that it be tried. -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples