| From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Absolute value of intervals |
| Date: | 2009-11-16 08:30:07 |
| Message-ID: | hdr2if$7af$1@reversiblemaps.ath.cx |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 2009-11-07, Joshua Berry <yoberi(at)gmail(dot)com> 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:
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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jasen Betts | 2009-11-16 08:46:46 | Re: Backups |
| Previous Message | Pavel Stehule | 2009-11-16 08:24:35 | Re: passing parameters to multiple statements |