Overlapping ranges

From: Jason Long <mailing(dot)lists(at)octgsoftware(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Overlapping ranges
Date: 2014-06-18 23:47:44
Message-ID: 1403135264.14348.5.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2014-06-19 00:08:33 Re: Overlapping ranges
Previous Message Dave Peticolas 2014-06-18 22:11:29 Question about detecting database changes