TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Data Diff – compare tables of any size across databases

127 pointsby hichkakeralmost 3 years ago
Gleb, Alex, Erez and Simon here – we are building an open-source tool for comparing data within and across databases at any scale. The repo is at <a href="https:&#x2F;&#x2F;github.com&#x2F;datafold&#x2F;data-diff" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;datafold&#x2F;data-diff</a>, and our home page is <a href="https:&#x2F;&#x2F;datafold.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;datafold.com&#x2F;</a>.<p>As a company, Datafold builds tools for data engineers to automate the most tedious and error-prone tasks falling through the cracks of the modern data stack, such as data testing and lineage. We launched two years ago with a tool for regression-testing changes to ETL code <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24071955" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24071955</a>. It compares the produced data before and after the code change and shows the impact on values, aggregate metrics, and downstream data applications.<p>While working with many customers on improving their data engineering experience, we kept hearing that they needed to diff their data across databases to validate data replication between systems.<p>There were 3 main use cases for such replication:<p>(1) To perform analytics on transactional data in an OLAP engine (e.g. PostgreSQL &gt; Snowflake) (2) To migrate between transactional stores (e.g. MySQL &gt; PostgreSQL) (3) To leverage data in a specialized engine (e.g. PostgreSQL &gt; ElasticSearch).<p>Despite multiple vendors (e.g., Fivetran, Stitch) and open-source products (Airbyte, Debezium) solving data replication, there was no tooling for validating the correctness of such replication. When we researched how teams were going about this, we found that most have been either:<p>Running manual checks: e.g., starting with COUNT(*) and then digging into the discrepancies, which often took hours to pinpoint the inconsistencies. Using distributed MPP engines such as Spark or Trino to download the complete datasets from both databases and then comparing them in memory – an expensive process requiring complex infrastructure.<p>Our users wanted a tool that could:<p>(1) Compare datasets quickly (seconds&#x2F;minutes) at a large (millions&#x2F;billions of rows) scale across different databases (2) Have minimal network IO and database workload overhead. (3) Provide straightforward output: basic stats and what rows are different. (4) Be embedded into a data orchestrator such as Airflow to run right after the replication process.<p>So we built Data Diff as an open-source package available through pip. Data Diff can be run in a CLI or wrapped into any data orchestrator such as Airflow, Dagster, etc.<p>To solve for speed at scale with minimal overhead, Data Diff relies on checksumming the data in both databases and uses binary search to identify diverging records. That way, it can compare arbitrarily large datasets in logarithmic time and IO – only transferring a tiny fraction of the data over the network. For example, it can diff tables with 25M rows in ~10s and 1B+ rows in ~5m across two physically separate PostgreSQL databases while running on a typical laptop.<p>We&#x27;ve launched this tool under the MIT license so that any developer can use it, and to encourage contributions of other database connectors. We didn&#x27;t want to charge engineers for such a fundamental use case. We make money by charging a license fee for advanced solutions such as column-level data lineage, CI workflow automation, and ML-powered alerts.

9 comments

alexkoayalmost 3 years ago
This seems to be very useful!<p>I notice that it casts everything to string for MD5 to work. In that case, how does it handle two databases having different types for the same columns? I&#x27;m thinking about floats and numerics (decimal places), timestamps (some have timezone support, some don&#x27;t) and bytes (hex, base64) in particular, but there are definitely others that I&#x27;m missing as well.
评论 #31853860 未加载
oa335almost 3 years ago
Hi, data engineer here. There are umpteen data engineering tools that have “Data” in the title. Have you considered a different name?
评论 #31847681 未加载
higeorge13almost 3 years ago
Awesome tool, we will definitely give it a try! 2 questions:<p>- how do you handle the data replication lag in the comparison?<p>- i assume that this works in identical tables between 2 databases, right? Any support for “similar” tables based on a column set? Imagine that we have a use case where we have a table X in one db, and another table Y in another db, with some columns from X and enhanced attributes.
评论 #31841450 未加载
pbnjayalmost 3 years ago
Pretty cool! I did a similar project for flatfiles, but used bloom filters to generate an “index” of row contents to test against later. I feel like a similar idea could work for identifying divergent rows within your segments more quickly&#x2F;with less repeated work.<p>Making that work across databases could be a huge pain though, I had some success in Postgre but bitfields in the other DBs were painful.
评论 #31845756 未加载
snidanealmost 3 years ago
What benefit does it give me over running table diff query in SQL?<p><pre><code> select * exclude (date_uploaded) from dev_table except select * exclude (date uploaded) from prod_table </code></pre> or<p><pre><code> select * from (select * exclude (date_uploaded) from dev_table) dev natural full join (select * exclude (date_uploaded) from prod_table) prod where dev.date_uploaded is null or prod.date_uploaded is null </code></pre> The only issue with the above is that EXCLUDE&#x2F;EXCEPT is missing from standard SQL and even from market leaders like Snowflake, making this a massive pain in the ass. Second, natural joining in presence of null fields is going to produce a mess instead of something useful. Again - analytics db providers would rather boast about adhering to an ancient standard from the 1970s than listening to users and actually making SQL work after all those decades of pain.<p>Without the stupid default behavior of SQL, this wouldn&#x27;t be a problem. I&#x27;m curious if Data Diff solves this or some other use case.
评论 #31845723 未加载
评论 #31845192 未加载
neural_thingalmost 3 years ago
I&#x27;ve been a Datafold customer for a year at two different companies. Great experience. Very useful tool in your CI flow, the team is very responsive.
jnsiealmost 3 years ago
Just curious - is there a reason that SQL Server doesn&#x27;t make the list of supported platforms (i.e. it appears that there is no plan to support in future)?
评论 #31843238 未加载
评论 #31843438 未加载
cryptonectoralmost 3 years ago
Does FDW let you do performant `FULL OUTER JOIN`s and&#x2F;or `NATURAL FULL OUTER JOIN`s? If so then I would think that would be a decent place to start for remote DB diffs for PG. If might not be enough, of course, if the tables are huge, in which case taking a page from rsync and using some sort of per-row checksum as TFA does is clearly a good idea.
评论 #31842694 未加载
michalgalmost 3 years ago
Can you diff a table with a view? Or only tables are supported?
评论 #31841462 未加载