Re: Overlapping ranges

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Overlapping ranges
Date: 2014-06-19 00:08:33
Message-ID: 53A22A01.2080705@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/18/2014 05:47 PM, Jason Long wrote:
> I have a large table of access logs to an application.
>
> I want is to find all rows that overlap startdate and enddate with any
> other rows.
>
> The query below seems to work, but does not finish unless I specify a
> single id.
>
> select distinct a1.id
> from t_access a1,
> t_access a2
> where tstzrange(a1.startdate, a1.enddate) &&
> tstzrange(a2.startdate, a2.enddate)
>
>
>
>
I'm sure you're best bet is a windowing function, but your descriptions
suggests there is no index on start/end date columns. Probably want
those in any event.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Long 2014-06-19 00:45:45 Re: Overlapping ranges
Previous Message Jason Long 2014-06-18 23:47:44 Overlapping ranges