Closed casey-chow closed 1 year ago
Does this change the default behavior where for example, prisma.user.findMany()
would use the primary writer/read DB?
But prisma.$replica().user.findMany()
would then use a reader instance?
If so, then great! That makes way more sense to me than having the default be reader instances.
Does this change the default behavior where for example, prisma.user.findMany() would use the primary writer/read DB? But prisma.$replica().user.findMany() would then use a reader instance?
No, it does not. This only allows the developer to control when to use a replica, especially when a query would otherwise hit the primary. The key use case is with $queryRaw
which currently hits the primary but I may want to hit a replica instead.
If so, then great! That makes way more sense to me than having the default be reader instances.
How so? The point of read replicas are to offload reads from the primary database instance, so changing this behavior to hit the primary by default largely defeats the purpose of having read replicas.
@casey-chow
How so? The point of read replicas are to offload reads from the primary database instance, so changing this behavior to hit the primary by default largely defeats the purpose of having read replicas.
Great point 🙂
Overall this looks good. I've left one question. After it is clarified, this is ready to be merged. Sorry it took longer to get to the review and thanks a lot for sending in the patch.
Overall this looks good. I've left one question. After it is clarified, this is ready to be merged. Sorry it took longer to get to the review and thanks a lot for sending in the patch.
Thanks @SevInf! I've made the fix, ptal.
Released in 0.3.0
To unstall https://github.com/prisma/extension-read-replicas/pull/18, I'm setting up a
$replica()
client-level call that forces use of a randomly-selected replica. This allows maximal developer control without sacrificing clarity for now, as suggested in https://github.com/prisma/extension-read-replicas/pull/18#issuecomment-1741314933.