Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
/ DEPRECATED-pgdatadiff Public archive
forked from dmarkey/pgdatadiff

Small python utility to diff the data between 2 postgres databases.

License

Notifications You must be signed in to change notification settings

calm/DEPRECATED-pgdatadiff

 
 

Repository files navigation

PGDataDiff

asciicast

Introduction

This is a small utility that given 2 PostgreSQL databases, will tell you what tables have different data. Specificaly it was developed to test replication is working correctly.

It compares table data and sequences. It won't tell you exactly what rows are different but a range of rows that are different (depending on --chunk-size parameter)

What it does not

Doesn't check that the schemas are the same.. i.e. stored procedures, indexes, contraints.. For this use a tool like https://www.postgrescompare.com/ or diff a schema dump from both databases.

How does it determine if table data is different?

Firstly it compares the row count in both tables.

If the row count is the same, it instructs postgres to create MD5 sums of "chunks" of the table in both DBs and compares them. This way no data is actually read directly by pgdatadiff, it also means that pgdatadiff is relatively fast but is puts a moderate amount of pressure on the DB as it calculates the MD5 sums of large amounts of data. The MD5 sums are based on the data being cast to varchar. If you have data types that don't cast to varchar properly then the behaviour probably wont be reliable.

If you have tables that have many columns, perhaps consider using a smaller --chunk-size, the default is 10000. Conversely if your tables have a small amount of columns with 100000's of rows, perhaps increase this value(it can increase the speed significantly).

Installation

The latest version can be installed using pip install pgdatadiff. Python 3.6+ is required.

Usage

Check pgdatadiff --help

Docker Images

Docker images are available.

docker run -it davidjmarkey/pgdatadiff:0.2.1 /usr/bin/pgdatadiff

About

Small python utility to diff the data between 2 postgres databases.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.2%
  • Shell 1.6%
  • Dockerfile 1.2%