Replies: 7 comments 10 replies
-
Feedback: The Prisma engine adds about 2MB to the Cloudflare D1 bundle size. This means that free tier users (with a 1MB bundle size limit) are unable to use Prisma without confusing errors. 😜 The minimum cost to use Prisma becomes $60/yr. I wound up switching to Drizzle for my project. Most of the engine seems to be a 2MB seems to be a giant webassembly file. Cloudflare doesn't count static assets against the 1MB limit. I wonder if there's a way to load it in asynchronously as a static asset rather than compiling it into the function. |
Beta Was this translation helpful? Give feedback.
-
Feedback: It's working generally well for me, I have a couple of smaller applications deployed already using the D1 adapter. However, my main application has more than 100 rows in almost every table and I'm running into trouble here: |
Beta Was this translation helpful? Give feedback.
-
I often write queries with many to many relationships being included, and it errors most of the time due to D1 having a very small parameter max length. I would really like to see joins being supported so I don't have to query raw. I am really happy with the performance. |
Beta Was this translation helpful? Give feedback.
-
feedback around the D1 developer workflow: Generally really nice & well thoughout. I have a use-case where my local |
Beta Was this translation helpful? Give feedback.
-
Do I understand correctly that in each loader I'd need to create a new prisma client, like this? const adapter = new PrismaD1(env.DB)
const prisma = new PrismaClient({ adapter }) Of course I can add a function to make it reusable, but is it how it's supposed to be used? What about export const getPrisma = (env: Env) => {
const adapter = new PrismaD1(env.DB)
const prisma = new PrismaClient({ adapter })
return prisma
} Are there any disadvantages of such approach? Is there a way to create a single instance of |
Beta Was this translation helpful? Give feedback.
-
Something's exploding here on inserts and it's killing performance. Here are some benchmarks from inserting 10, 100, 1000 new rows using
You can test the worker version here, which is running the code from this repo/branch export async function writeProperties(count: number) {
const t0 = performance.now()
const data = Array.from({ length: count })
.fill(null)
.map(() => ({ key: createId(), value: createId() }))
const t1 = performance.now()
await prisma.property.createMany({
data,
})
const t2 = performance.now()
const values = Array.from({ length: count })
.fill(null)
.map(() => `('${createId()}', '${createId()}')`)
.join(', ')
const sql = `INSERT INTO Property (key, value) VALUES ${values}`
const t3 = performance.now()
await prisma.$executeRawUnsafe(sql)
const t4 = performance.now()
const values2 = Array.from({ length: count })
.fill(null)
.map(() => `('${createId()}', '${createId()}')`)
.join(', ')
const sql2 = `INSERT INTO Property (key, value) VALUES ${values2}`
const t5 = performance.now()
await process.env.DB.exec(sql2)
const t6 = performance.now()
return {
'D1.exec': t6 - t5,
'Prisma.createMany': t2 - t1,
'Prisma.$executeRawUnsafe': t4 - t3,
}
}
|
Beta Was this translation helpful? Give feedback.
-
I have feedback regarding the D1 adapter. From what I am seeing in the logs, nested reads are not being done on either the |
Beta Was this translation helpful? Give feedback.
-
Support for the Cloudflare D1 is in preview behind the
driverAdapters
preview feature with the release of 5.12.0 on April 2nd.Please share your feedback about
@prisma/adapter-d1
in this discussion.Beta Was this translation helpful? Give feedback.
All reactions