Which datatype should be used for currency?

Your source is in no way official. It dates to 2011 and I don’t even recognize the authors. If the money type was officially “discouraged” PostgreSQL would say so in the manual – which it doesn’t.

For a more official source, read this thread in pgsql-general (from just this week!), with statements from core developers including D’Arcy J.M. Cain (original author of the money type) and Tom Lane:

Related answer (and comments!) about improvements in recent releases:

Basically, money has its (very limited) uses. The Postgres Wiki suggests to largely avoid it, except for those narrowly defined cases. The advantage over numeric is performance.

decimal is just an alias for numeric in Postgres, and widely used for monetary data, being an “arbitrary precision” type. The manual:

The type numeric can store numbers with a very large number of digits.
It is especially recommended for storing monetary amounts and other
quantities where exactness is required.

Personally, I like to store currency as integer representing Cents if fractional Cents never occur (basically where money makes sense). That’s more efficient than any other of the mentioned options.

Leave a Comment