4 ms·
I think the money type is awesome! Under the hood it uses int (I believe int32 even on 64bit) so it takes 50% less space than decimal. So if your only dealing
by troyk 12y ago
I think the money type is awesome! Under the hood it uses int (I believe int32 even on 64bit) so it takes 50% less space than decimal.
So if your only dealing with US currency, why not love the money type?
- rpedela 12y agoPostgres developers disagree and recommend numeric. It was once deprecated and then un-deprecated. http://www.postgresql.org/message-id/b42b73150805270629h309f3704i72c259081d8d393d@mail.gmail.com http://www.postgresql.org/message-id/b42b73150805270629h309f...
- troyk 12y agoI don't know, I followed the thread and it didn't seem conclusive, esp with the main criticizer stating "OTOH, it's a neat example of a fixed precision integer type" I use it a lot, and yes, it is missing some casts but you can cast to decimal and go from there: select '42.00'::money::decimal; I've also used stripe, and maybe it's a javascript thing, but they represent all their money in cents. Personally, I'd rather use the money type, it is easy for me to reason about.
- sitharus 12y agoJavascript represents all numbers as IEEE 754 floating point. Base 2 floating point isn't good for representing base 10 decimals.
- stuki 12y agoBecause pretty soon you will deal with a non US currency..... For a "datatype" as commonly needed as "money", it has always struck me as strange that a more standardized and widely agreed upon approach to dealing with them, have not emerged.
- callesgg 12y agoWhy would it make any difference if one used different currency's. As the currency of money is not known it is pretty obvious that one needs to store that in another column.