Unix Technical Forum

Whole-row comparison ?

This is a discussion on Whole-row comparison ? within the pgsql Sql forums, part of the PostgreSQL category; --> Hi there, I'm trying to implement a "versionned" storage for a datawarehouse system, meaning I have tables which store ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 03:25 PM
christian.roche.ext@nsn.com
 
Posts: n/a
Default Whole-row comparison ?

Hi there,

I'm trying to implement a "versionned" storage for a datawarehouse
system, meaning I have tables which store daily information about
objects and I would like to have a row inserted (i.e. a new version)
only if it differs from the most recent existing row. For instance
instead of storing

version attribute1 attribute2
1 x y
2 x y
3 x y
4 z y
5 z y
6 z t

we would only keep the diffs :

version attribute1 attribute2
1 x y
4 z y
6 z t

This would save lots of space and the full table could be easily
accessed through a view.

However as the tables have a large number of rows (several hundreds) I
would like to avoid having to write conditions like WHERE (old.att1 !=
new.attr1 or old.attr2 != new.attr2 or ... or old.attr245 != new.attr245
)

So my question is: is there a way to do some kind of whole-row
comparison ? For instance a hash of the full row or something similar ?
Is there a standard way of solving this problem ?

Thanks a lot for any hind !
Christian

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:25 PM
Richard Broersma Jr
 
Posts: n/a
Default Re: Whole-row comparison ?

> So my question is: is there a way to do some kind of whole-row
> comparison ? For instance a hash of the full row or something similar ?
> Is there a standard way of solving this problem ?


Sure it is called row wise comparison:
http://www.postgresql.org/docs/8.2/i...ISE-COMPARISON

you can write something like:

SELECT *
FROM Your_table
WHERE (c1,c2,c3,c4) = ('a',2,'xyz',123);

Regards,
Richard Broersma Jr.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com