Re: need to join successive log entries into one

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: George Young <gry(at)ll(dot)mit(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: need to join successive log entries into one
Date: 2001-03-14 21:07:35
Message-ID: 200103142107.f2EL7ZG21981@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

George Young wrote:
...
>I need to produce a new table that coalesces immediately successive
>operations on a run into one, e.g.:
>
>run | start | done
> 1415| 2001-01-29 12:36:55| 2001-02-07 13:02:38
> 1415| 2001-02-14 07:40:04|
> 1747| 2001-02-15 09:14:39| 2001-03-01 09:02:39
> 1747| 2001-03-05 13:13:58|
> 1954| 2001-02-02 20:55:39| 2001-03-02 10:17:15
>
>i.e. where a run has one or more steps with succesive seq values,
>or equivalently, with abutting start/end values, then I want
>the new table to have only one entry representing the full span of
>time. Null 'done' just means it's not done yet.
...
>Can anyone think of a way I can do this in postgres?

I think you would be better off feeding the log out of the database into
a perl script. SQL is a set-oriented language that can't do this
sort of thing without some appalling contortions, if at all. (I can't
think of a way to do it.) So, store the data in PostgreSQL, but do
procedural processing in a more appropriate language.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Let your light so shine before men, that they may see
your good works, and glorify your Father which is in
heaven." Matthew 5:16

Browse pgsql-sql by date

  From Date Subject
Next Message Richard H 2001-03-14 21:17:33 Re: need to join successive log entries into one
Previous Message Josh Berkus 2001-03-14 21:00:48 FETCH ... INTO in PL/pgSQL