Re: partitioning a dataset + employing hysteresis condition

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: Amit Dor-Shifer <amit(dot)dor(dot)shifer(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: partitioning a dataset + employing hysteresis condition
Date: 2011-11-15 22:01:28
Message-ID: 4EC2E138.5050303@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 14/11/11 18:35, Amit Dor-Shifer wrote:
>
> On Mon, Nov 14, 2011 at 4:29 PM, Amit Dor-Shifer
> <amit(dot)dor(dot)shifer(at)gmail(dot)com <mailto:amit(dot)dor(dot)shifer(at)gmail(dot)com>> wrote:
>
> Hi,
> I've got this table:
> create table phone_calls
> (
> start_time timestamp,
> device_id integer,
> term_status integer
> );
>
[...]

3 points

POINT 1:
I should have given the results of my attempt...

[...]
device_id
-----------
2
40
50
60
(4 rows)

POINT 2:
I also realized I left of a condition in the HAVBING part

HAVING
max(pc1.start_time) >= min(pc1.start_time) + interval '2 minute'

I think it should be

HAVING
max(pc1.start_time) >= min(pc1.start_time) + interval '2 minute'
AND pc1.term_status = 2

POINT 3:
Timestamps should almost always be stored with a time zone (using
timestamptz rather than just timestamp) -- or you will have problems
when Summer time ends or begins, and using timestamptz allows for
date&time to be displayed currectly in different locales.

Regards,
Gavin

P.S. Since my post has not shown up yet, I had to attach to its parent!
(I won't offer my first born to get direct posting rights,
as his wife may object -
besides which, it is probably illegal in my jurisdiction!)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-11-15 22:21:05 Questions about "EXPLAIN"
Previous Message Peter Eisentraut 2011-11-15 21:00:40 Re: syntax highlighting in emacs after \e in psql