Re: Compare rows - Mailing list pgsql-performance

From Greg Spiegelberg
Subject Re: Compare rows
Date
Msg-id 3F8459FA.1030008@cranel.com
Whole thread Raw
In response to Re: Compare rows  (Joe Conway <mail@joeconway.com>)
Responses Re: Compare rows
List pgsql-performance
Joe Conway wrote:
> Greg Spiegelberg wrote:
>
>> The reason for my initial question was this.  We save changes only.
>> In other words, if system S has row T1 for day D1 and if on day D2
>> we have another row T1 (excluding our time column) we don't want
>> to save it.
>
>
> It still isn't entirely clear to me what you are trying to do, but
> perhaps some sort of calculated checksum or hash would work to determine
> if the data has changed?

Best example I have is this.

You're running Solaris 5.8 with patch 108528-X and you're collecting
that data daily.  Would you want option 1 or 2 below?

Option 1 - Store it all
  Day  |      OS     |   Patch
------+-------------+-----------
Oct 1 | Solaris 5.8 | 108528-12
Oct 2 | Solaris 5.8 | 108528-12
Oct 3 | Solaris 5.8 | 108528-13
Oct 4 | Solaris 5.8 | 108528-13
Oct 5 | Solaris 5.8 | 108528-13
and so on...

To find what you're running:
select * from table order by day desc limit 1;

To find when it last changed however takes a join.


Option 2 - Store only changes
  Day  |      OS     |   Patch
------+-------------+-----------
Oct 1 | Solaris 5.8 | 108528-12
Oct 3 | Solaris 5.8 | 108528-13

To find what you're running:
select * from table order by day desc limit 1;

To find when it last changed:
select * from table order by day desc limit 1 offset 1;

I selected Option 2 because I'm dealing with mounds of complicated and
varying data formats and didn't want to have to write complex queries
for everything.

Greg

--
Greg Spiegelberg
  Sr. Product Development Engineer
  Cranel, Incorporated.
  Phone: 614.318.4314
  Fax:   614.431.8388
  Email: gspiegelberg@Cranel.com
Cranel. Technology. Integrity. Focus.



pgsql-performance by date:

Previous
From: Neil Conway
Date:
Subject: Re: Sun performance - Major discovery!
Next
From: Jeff
Date:
Subject: Re: [HACKERS] Sun performance - Major discovery!