Back to Prisma

Using @db.Money

apps/docs/content/docs.v6/postgres/query-optimization/recommendations/avoid-db-money.mdx

latest887 B
Original Source

Optimize provides recommendations to help you identify and resolve performance issues caused by the use of @db.Money type.

The following model uses the @db.Money native type:

prisma
model Item {
  // ...
  price Decimal @db.Money
  // ...
}

What is the problem?

The @db.Money data type in PostgreSQL is not ideal for storing monetary values. Internally, @db.Money is implemented as an integer, which offers speed but lacks flexibility. It handles fractional values and rounding in unexpected ways, which can lead to inaccuracies.

Additionally, the @db.Money type does not store any information about the associated currency. Instead, it relies on the global lc_monetary locale setting, which may not be suitable for all use cases.

For more information, refer to the PostgreSQL documentation.