The Postgres Wiki recommends avoiding the Money type, except for "narrowly defined cases," as performance is its main advantage. But a more official source contradicts this claim, stating that the Money type is not officially discouraged.
When considering currency storage options in Postgres, it is important to note that decimal is simply an alias for numeric. The Postgres manual specifically recommends numeric for "storing monetary amounts and other quantities where exactness is required."
For precise currency representation, numeric offers arbitrary precision and is widely used for monetary data. However, for situations where fractional cents are not relevant, integer representing Cents provides increased efficiency.
Ultimately, the choice of datatype depends on the specific requirements of your application, considering factors such as performance and precision requirements.
The above is the detailed content of Numeric or Integer: What's the Best PostgreSQL Datatype for Storing Currency?. For more information, please follow other related articles on the PHP Chinese website!