On 2024-02-15 16:51:56 -0700, David G. Johnston wrote:
> On Thu, Feb 15, 2024 at 4:31 PM Peter J. Holzer <hjp-pgsql@xxxxxx> wrote:
> On 2024-02-14 22:55:01 -0700, David G. Johnston wrote:
> > On Tuesday, February 13, 2024, veem v <veema0000@xxxxxxxxx> wrote:
> >
> > float data types rather than numeric. This will give better
> > performance.
> >
> >
> > Only use an inexact floating-point data type if you truly
> > understand what you are getting yourself into. Quickly getting
> > the wrong answer isn’t tolerable solution.
>
> Do NOT assume that a decimal type (even if it can grow to ridiculuous
> lengths like PostgreSQL's numeric) is exact in the mathematical sense.
> It isn't. It cannot represent almost all real numbers
>
>
Thank You.
So it looks like the use cases where we don't need precision or decimal point values to be stored in postgres , integer data type is the way to go without a doubt.
However in cases of precision is required, as you all mentioned there are certain issues(rounding error etc) with "Float" data type and considering a normal developers usage point of view, it should be the Numeric type which we should use. I think the consistent working or functionality of an application takes precedence over performance. And I believe , in most real life scenarios, when we need precisions we expect them to behave consistently across all the application and database platforms(mainly banking industries), and thus it seems Numeric data type is the safest one to use as a multi database platform type. Please correct me if I'm wrong.
Regards
Veem