PrismaP
Prisma2y ago
yahya

Super slow queries when filter JSON

Hello, I asked the same question to @kapa.ai but couldn't figure out what to do

basically my queries are super slow when running filters on raw JSON values with postgresql

should I switch to mongodb?

await prisma.dataEntry.findMany({
 where:{ ...,
       AND: [
            {
              raw: { path: [key], not: "" },
            },
            {
              raw: { path: [key], not: Prisma.DbNull },
            },
            {
              raw: { path: [key], not: Prisma.JsonNull },
            },
          ]
},
...
})


model DataEntry {
    id String @id @default(cuid())

    raw Json

    upload   DataUpload @relation(fields: [uploadId], references: [id], onDelete: Cascade)
    uploadId String
    users    User[]

    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
}


what can I do?
Was this page helpful?