Optimizing Database Access Strategy: A Performance Analysis Comparison of Raw SQL and Prisma ORM
This study presents a performance benchmarking analysis comparing two database access strategies: Prisma ORM and optimized raw SQL on PostgreSQL. The evaluation involves eight distinct query patterns executed within containerized environments using a relational dataset comprising more than 15 interrelated tables. Key performance metrics observed include CPU utilization, memory consumption, query execution time, and overall system stability. The experimental results consistently demonstrate that raw SQL significantly outperforms Prisma ORM across all tested metrics. Specifically, raw SQL achieves execution speeds up to five times faster, while using 6 to 9 times less CPU and 2 to 3 times less memory compared to Prisma. These findings highlight the substantial overhead introduced by Object-Relational Mapping (ORM) abstractions such as Prisma, particularly in performance-sensitive environments. By isolating the performance impact of the ORM layer, this study provides critical insights into how abstraction convenience can come at the cost of efficiency. The results highlight the importance of deliberate consideration when selecting database access technologies, particularly for applications that require high throughput and minimal latency. While ORMs offer development speed and maintainability, raw SQL proves to be a superior choice when optimizing for execution performance and system resource utilization. This benchmark serves as a valuable reference for developers, architects, and researchers aiming to strike a balance between productivity and performance in modern software systems.
Authors
- Kristien Margi Suryaningrum
- Rector Arya (ORCID: https://orcid.org/0000-0001-7372-5043)
- Ricky Reynardo Siswanto
- Joseph Christian Yusmita
- Jason Manuel Wijaya
Institutions
- Binus University (ID)
Publication Details
- Journal
- Procedia Computer Science
- Published
- 2025-01-01
- DOI
- https://doi.org/10.1016/j.procs.2025.09.061
- Primary Topic
- Advanced Database Systems and Queries
- Type
- article
- Field-Weighted Citation Impact
- 0.00