Back to Prisma

Using @db.VarChar(n)

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

latest694 B
Original Source

Optimize provides recommendations to help you identify and resolve performance issues caused by the use of @db.VarChar(n) type in PostgreSQL.

The @db.VarChar(n) native type has been used within the Item model on the name field:

prisma
model Item {
  // ...
  name String @db.VarChar(1)
  // ...
}

Why this is a problem

The @db.VarChar(n) type restricts content to a maximum length of n, which can cause unexpected issues in production if not properly managed by the application. In PostgreSQL, varchar(n) performs the same as text, and no additional optimizations are provided for varchar(n), making the choice between them more about convention than performance.