Re: Is there an md5sum for tables? - Mailing list pgsql-general

From Volkan YAZICI
Subject Re: Is there an md5sum for tables?
Date
Msg-id 87fxu4y7xn.fsf@alamut.mobiliz.com.tr
Whole thread Raw
In response to Is there an md5sum for tables?  (Michael Enke <michael.enke@wincor-nixdorf.com>)
List pgsql-general
Michael Enke <michael.enke@wincor-nixdorf.com> writes:
> I need to know if multiple tables have (may have most probably)
> identical content.

That sounds me you should re-consider your database design. Having PK/FK
relations is the reason we divide common parts into separate tables to
avoid from data duplication.

> Since I want a fast solution (which means not comparing tables row by
> row), I thought it would be a good idea to have an sql function
> operating on a table or view similar to md5sum on a file and only
> compare the generated hashes.  I did not find such a function in the
> documentation.

First alter related tables and prepend a hash field to each one. After
that, you can implement your own PL/pgSQL procedure which takes a table
name and queries supplied table's columns from information_schema and
builds an SQL query string to concatenate MD5 hash of available table
fields into a single field, and updates hash field of each field
according to computed hash.


Regards.

pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: simple update queries take a long time - postgres 8.3.1
Next
From: Greg Smith
Date:
Subject: Re: simple update queries take a long time - postgres 8.3.1