Re: [BUGS] BUG #14648: counts for queries using array unnesting is incorrect - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: [BUGS] BUG #14648: counts for queries using array unnesting is incorrect
Date
Msg-id CAKFQuwYRNvL3xR2NOm9V=9G1LRpLcAc5a=6Du-NbVkXa3UU6ow@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14648: counts for queries using array unnesting is incorrect  (Sebastion Calbaza <sebastian.calbaza@hgdata.com>)
Responses Re: [BUGS] BUG #14648: counts for queries using array unnesting is incorrect  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Sun, May 14, 2017 at 11:29 PM, Sebastion Calbaza <sebastian.calbaza@hgdata.com> wrote:
You are correct, this is how it behaves.
For my dev mind (probably for others ) this was pretty non intuitive. In the end I used array_length and sum to compute the count.

Still,  is this the intended behaviour (I guess so from a mathematical point of view ?? )? If it is I can argue that is not too intuitive and adding a doc note near the unnest function description would be good.


Yes, its intentional, and it isn't specific to just the unnest function so documenting it just there doesn't seem correct.  I don't know where it is documented but I suspect that even just reading the documentation for this would be of minimal help - I think its likely best learned after experiencing the aforementioned problem.

David J.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] Commenting a FK crashes ALTER TABLE statements
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14648: counts for queries using array unnesting is incorrect