Search Postgresql Archives

Re: Absolute value of intervals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2009-11-07, Joshua Berry <yoberi@xxxxxxxxx> wrote:
> On Mon, Nov 2, 2009 at 8:35 AM, Jasen Betts <jasen@xxxxxxxxxx> 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:

indeed, this one should be more efficient but is not exactly identical.

select * from enviados e, recibidos r where e.fecha between  r.fecha
-'1s' and r.fecha +'1s';

the difference being that the above includes the case where the
difference is exactly 1 second.

this might work better:

select * from enviados e, recibidos r where e.fecha between  r.fecha 
-'0.999999s' and r.fecha +'0.999999s'; 

it depends how critical the edge cases are.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux