Drizzle vs Prisma: A Comprehensive Comparison 🚀

BazaarNXT
3 min readOct 11, 2023

Introduction

Drizzle and Prisma, both prominent Object-Relational Mappers (ORMs) for Node.js, serve as indispensable tools in simplifying database interactions for developers. This post delves into a thorough performance comparison between the two, exploring benchmarks, strengths, and weaknesses.

Benchmark Setup

Node.js Project

  • Language: TypeScript
  • Dependencies:
  • Drizzle: ^1.99.0
  • Prisma: ^3.12.0
  • Postman Runner: ^8.10.0

PostgreSQL Database

  • Provider: Digital Ocean Managed Database
  • Size: 1 GB RAM
  • CPU: 1 vCPU

Benchmarks

The benchmarks conducted included:

  • Fetch all Cities: Retrieves all cities worldwide from the database.
  • Insert a new City: Adds a new city entry into the database.
  • Update a City Info: Modifies information for a city in the database.
  • Delete a City: Removes a city entry from the database.

The worldDB-1.0 database from here was chosen for its well-designed real-world structure, providing diverse scenarios for testing different ORMs.

đź’ˇ Two types of benchmark tests were conducted: 1. Synthetic benchmark and 2. Stress and Performance benchmark.

Results for Synthetic Benchmarks

Drizzle ORM:

Prisma ORM:

Discussion

Drizzle consistently outperformed Prisma across all benchmarks, with the most significant disparities observed in “Select all cities” and “Delete a city,” where Drizzle exhibited nearly twice the speed of Prisma. Potential factors contributing to this performance gap include Drizzle’s optimization and its adept utilization of PostgreSQL features, notably the “Prepared Statement” performance optimization feature, which was not employed in this test. 🚄

Results for Stress and Performance Benchmark

Load testing using Postman Runner provided insights into how Drizzle and Prisma handled concurrent requests:

Drizzle demonstrated superior performance, managing 20 virtual users (VUs) with an average response time of 17 ms, while Prisma struggled with an average response time of 1565 ms and an error rate of 2.21%. Clearly, Drizzle outperformed Prisma with a whooping ~200% difference! 🏆

Conclusions

While Drizzle excels in both performance and load tests, it’s essential to acknowledge its status as a relatively new ORM with limited documentation and community support. On the flip side, Prisma stands out for its developer-friendly approach, supported by extensive documentation and compatibility with multiple databases, both relational and non-relational.

When deciding between Drizzle and Prisma, your project’s specific requirements should be the guiding factor. For small-scale applications with basic database needs and a preference for simplicity, Drizzle might be a suitable choice. However, for those seeking advanced features, optimal performance, and a vibrant community, Prisma emerges as the more comprehensive option. 🤔✨

--

--

BazaarNXT is one-stop business e-commerce platform selling a wide range of packaging material products to SMEs as well as large businesses.