Skip site navigation (1) Skip section navigation (2)

How should I do this?

From: Laurent Duperval <lduperval(at)videotron(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: How should I do this?
Date: 2002-06-26 22:53:59
Message-ID: afdgm3$ekr$ (view raw, whole thread or download thread mbox)
Lists: pgsql-general

I'm trying to do a couple of things:

I have a lot of data in a database which is structured as follows:

date: long
value: numeric
delta: numeric

What happens is that sometimes the value and delta fields can be identical
for a long period. This data is used to produce graphs so having a number of
rows with the same value and delta but with different times just wastes space.
How would I make sure that insertions occur only if delta and/or value are
different than the last entry in the table?

Secondly, now I've got a lot of this useless data in my table. What's the best
way to clean it out e.g. if my data is:

1 10 1
2 10 1
3 10 1
4 11 2
5 9 0
6 9 0
7 9 0
8 7 -2

I only want 

1 10 1
4 11 2
5 9 0
8 7 -2

left in the table. Note that I'm using the Pgtcl extension and I can script it
in Tcl. My original idea was to do a select to get all the data in the tables
and then go through them one by one and to remove a row if the delta/value is
different from the previous one. But maybe there's a better way?

Thanks for any ideas,


Laurent Duperval <mailto:lduperval(at)videotron(dot)ca>

"I realized that the purpose of writing is to inflate ideas, obscure poor
reasoning, and inhibit clarity."


pgsql-general by date

Next:From: Martijn van OosterhoutDate: 2002-06-26 23:23:41
Subject: Re: unlimited undo/journaling
Previous:From: BenDate: 2002-06-26 22:48:36
Subject: Re: Advocacy Idea.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group