Prisma Data Proxy vs Drizzle

Has anyone tried Prisma's data proxy? I'm currently just using Prisma regularly and it takes ~ 3 - 5 seconds to fetch a simple array from my DB and it's extremely inconsistent with response times varying, I use nextJS to write my API call
export async function GET(request: Request) {
try {
const url = new URL(request.url);
const topicId = parseInt(url.searchParams.get("topicId") ?? "", 10);
console.log("Received topicId:", topicId);

const topic = await db.topic.findUnique({
where: {
id: topicId,
},
include: {
subtopics: {
select: {
name: true,
},
},
},
});

if (!topic) {
return new Response(null, { status: 404 });
}

const subtopicNames = topic.subtopics.map((subtopic) => subtopic.name);

return new Response(JSON.stringify(subtopicNames));
} catch (error) {
return new Response(null, { status: 500 });
}
}
export async function GET(request: Request) {
try {
const url = new URL(request.url);
const topicId = parseInt(url.searchParams.get("topicId") ?? "", 10);
console.log("Received topicId:", topicId);

const topic = await db.topic.findUnique({
where: {
id: topicId,
},
include: {
subtopics: {
select: {
name: true,
},
},
},
});

if (!topic) {
return new Response(null, { status: 404 });
}

const subtopicNames = topic.subtopics.map((subtopic) => subtopic.name);

return new Response(JSON.stringify(subtopicNames));
} catch (error) {
return new Response(null, { status: 500 });
}
}
Client Side: This call takes around 3-5 seconds from making the request to rendering it on the client side (I use react query on the client side). I was wondering if I use Prisma's data proxy would this be noticably faster? I'm aiming for around < 1s to 1s but as long as it's faster idm. Prisma's data proxy allows you to use the edge with Prisma which I'd rather do instead of switching to Drizzle however if Prisma's data proxy is still significantly slower than Drizzle I'd rather make the switch. The biggest issue rn is cold starts which is why I want to use the edge, in their docs Prisma advertises "Faster cold starts" but I'm not sure how much faster it'll be. I console logged the time the response would take and the first (cold start) req takes: 2640.547416985035 milliseconds (2.6s) and after that it takes 487.4787500202656 milliseconds (0.487s). Is it worth using Prisma's data proxy or should I just switch to Drizzle? Thanks
3 Replies
wlvz
wlvzOP2y ago
Just to add, I'm aware Drizzle is a lot better performance wise however Prisma is a lot easier to work with IMO and I love Prisma Studio and I'd rather not give it up.
Manupa Samarawickrama
It all depends on scale If you use want the prisma dx you can opt for the data proxy, but make sure you stay on the free tier otherwise its another expense you can start with prisma data proxy and move to drizzle later
Manupa Samarawickrama
or you can use planetscale edge driverhttps://github.com/planetscale/database-js
GitHub
GitHub - planetscale/database-js: A Fetch API-compatible PlanetScal...
A Fetch API-compatible PlanetScale database driver - GitHub - planetscale/database-js: A Fetch API-compatible PlanetScale database driver
Want results from more Discord servers?
Add your server