DEV Community

Cover image for ORM vs Core Database Driver
Sami Salih İbrahimbaş
Sami Salih İbrahimbaş

Posted on

3 2

ORM vs Core Database Driver

Greetings, in this article we will briefly talk about the comparison of ORM and database drivers and which one you should perfer in which situation.

ORM Pros and Cons

Pros

  • Schemas/Entites are clearly defined.
  • Relatively easy to understand and develop
  • You can write basic Queries with built-in query-builders
  • You don't bother too much with database operations

Cons

  • Low performance
  • As it is a pattern applied on top of the engine, it may restrict some advanced operations
  • Extra dependencies and possible size growth for the project (the item may sound trivial but will be important when using docker and etc.)

Database Driver Pros and Cons

Pros

  • High performance
  • Takes up minimal space
  • Trouble-free guarantee and full documentation as it was developed by the database company

Cons

  • May require expertiese with queries and databases
  • Schemas are not clearly defined or have no effect on the database

When, Which?

If you are developing a simple demo, developing a blog, or if time and performance (included build time and performance) is not important to you; your choice should be ORM.

If time and performance (included build time and performance) is your thing, if you're a database expert; your choice should be Core Database Driver.

Here is an article measuring the differences between mongodb and mongoose, there is a really big performance difference.

If you're lazy, there's a table like this at the end of the article.

READS Native Mongoose
Throughput 1200 #/sec 583 #/sec
Avg Request 0.83 ms 1.71 ms
WRITES Native Mongoose
Throughput 1128 #/sec 384 #/sec
Avg Request 0.89 ms 2.60 ms

Whay do you think about this subject?

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay