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?
Top comments (0)