I'm working with large integer numbers, which I currently represent in PG using numeric(x, 0)
. I don't want to think about x
each time, so I'm wondering:
Is there any benefit (storage, performance, etc.) to use numeric(x, 0)
instead of just the generic numeric
?
Constrained numeric(x,0)
is used to ensure that numbers are rounded to one, regardless of the format in which they are entered.
select 1.8::numeric(50,0)
numeric
---------
2
(1 row)
When it comes to performance, the difference between the use of constrained and unconstrained numerics is negligible.