---
title: "Same rows, different SUM"
url: https://daily.dev/posts/same-rows-different-sum-barwhgtrw
source_url: https://postgr.es/p/9nx
type: article
source: "Planet PostgreSQL"
published: 2026-06-28T19:48:49.589Z
updated: 2026-06-29T06:20:33.195Z
tags: ["postgresql"]
reading_time: 12
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Same rows, different SUM

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 12 min read · 1 upvotes · 0 comments

## Summary

Running the same SUM query on a PostgreSQL table of double precision floats can produce different results across executions without any data changes. The cause is parallel aggregation: workers split rows non-deterministically and return partial sums in varying order, and since floating-point addition is not associative, different groupings produce different rounding errors. Disabling parallelism yields a stable result, but that stable result is still wrong compared to the exact value. The real fix is using the numeric type for any column whose aggregate must be reproducible or reconcilable. For genuinely approximate data like sensor readings, accept the imprecision and avoid asserting exact equality on float aggregates.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9nx>

## Similar posts on daily.dev

- [The DISTINCT in your COUNT](https://daily.dev/posts/the-distinct-in-your-count-ieqwekrgt) · Planet PostgreSQL · 0 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/same-rows-different-sum-barwhgtrw)
