Re: Non-deterministic behavior with floating point in parallel mode

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ruben Buchatskiy <ruben(at)ispras(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org, amit(dot)kapila16(at)gmail(dot)com
Subject: Re: Non-deterministic behavior with floating point in parallel mode
Date: 2017-02-02 14:49:20
Message-ID: 3455.1486046960@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ruben Buchatskiy <ruben(at)ispras(dot)ru> writes:
> We have found that in parallel mode result of queries is non-deterministic
> when the types of the attributes in table are double precision
> (floating-point).

Yeah ...

> That is because floating-point addition is not necessarily associative.

Right, exactly.

> Is this desirable behavior?

It's not especially the fault of parallelism. Any change in the order in
which the SUM visits the rows could cause a similar change in the results.
IOW, you are being overoptimistic about how deterministic this result
is any of the time.

Use numeric, not float, if you can't tolerate this sort of behavior.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2017-02-02 15:16:29 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Previous Message Petr Jelinek 2017-02-02 14:37:00 Re: Enabling replication connections by default in pg_hba.conf