index without preview feature

Howdy, I have a user model that I frequently search on with where {}. I wanted to improve performance and read about indices with postgresql. I found that this is a preview feature on the docs, but my handy AI assistant claims I can just do this:
model User {
id Int @id @default(autoincrement())
firstName String
lastName String
// ... other fields ...

@@index([firstName])
@@index([lastName])
}
model User {
id Int @id @default(autoincrement())
firstName String
lastName String
// ... other fields ...

@@index([firstName])
@@index([lastName])
}
Does this work out of the box? Will this create an index for those fields in my postgres db and improve performance? Appreciate the help, folks!
2 Replies
Fr0xy
Fr0xy4mo ago
I dont think this is a preview feature, here is the doc: https://www.prisma.io/docs/orm/prisma-schema/data-model/indexes
Indexes | Prisma Documentation
How to configure index functionality and add full text indexes
Fr0xy
Fr0xy4mo ago
I am using this often
Want results from more Discord servers?
Add your server