From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Joshua Berry <yoberi(at)gmail(dot)com> |
Cc: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Absolute value of intervals |
Date: | 2009-11-10 18:42:10 |
Message-ID: | 200911101842.nAAIgAX22458@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Joshua Berry wrote:
> On Mon, Nov 2, 2009 at 8:35 AM, Jasen Betts <jasen(at)xnet(dot)co(dot)nz> wrote:
> |
> | for this case: convert to seconds and then do abs.
> |
> | ?select * from enviados e, recibidos r where abs(extract ( epoch from
> | ?(e.fecha - r.fecha) )) < 1
>
> Cheers for that. The query cost is pretty heavy, but the same as the
> following query which involves two WHERE sections:
>
> | select * from enviados e, recibidos r where (e.fecha - r.fecha) <
> | interval '1 second' AND (r.fecha - e.fecha) < interval '1 second'
>
> But both have a higher cost than the following query with "OVERLAPS"
>
> | select * from enviados e, recibidos r where (r.fecha + interval '1
> | seconds', r.fecha - interval '1 seconds') OVERLAPS (e.fecha, e.fecha);
>
> We're only talking about a 4% difference on estimated costs in the
> billions, but it made me wonder if I should be using OVERLAPS more
> regularly as it may be more highly optimized.
>
> | thanks for sparking an interesting discussion.
>
> Thanks. I feel a bit humbled by thinking that I could help add an
> operator that didn't exist simply because no one had gotten around too
> it! I realize now that it's a lot more complex of an issue than I
> thought it was.
I have added a C comment the references this discussion so we remember
why the function does not exist:
Add C comment about why there is no interval_abs(): it is unclear what
value to return:
http://archives.postgresql.org/pgsql-general/2009-10/msg01031.php
http://archives.postgresql.org/pgsql-general/2009-11/msg00041.php
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2009-11-10 21:43:15 | Re: [HACKERS] PostgreSQL 8.3.8 on AIX5.3 : compilation failed |
Previous Message | Magnus Hagander | 2009-11-10 17:46:37 | Re: Problem to use remote cygwin server using ssh and native psql 8.3.5 |