Prisma is indeed joining data in the Rust-based query engine rather than on a DB-level 👍
The main reason for this is that depending on the data set, the execution of JOINs inside of the DB would be
more costly than joining it in memory as we do. This is especially true for larger data sets in most real world apps. And for smaller datasets the
actual performance degradation can usually be entirely neglected because even though the queries might not be
fully optimized, there will be virtually no impact on the perceived performance by the user. That’s the tradeoff based on which we’ve implemented the current querying strategy.
While we are planning to make the query execution more flexible in the future to also give developers more options for deciding on a query plan, this approach has been working really well since we released Prisma for production and we’ve rarely seen any actual performance complaints (and if someone is
actually running into performance issues with Prisma, we’re quite fast to react on GitHub and resolve the performance issues).
There’s a
GitHub issue about this here with an interesting discussion going on where you can read more about this. There’s also a nice chapter about
“Query Performance Optimization” by O’Reilly.