Databases for REAL
Making databases easier
Issue: 9.5 (July/August 2011)
Article Description: No description available.
Article Length (in bytes): 4,430
Starting Page Number: 74
RBD Number: 9511
Resource File(s): None
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Last time we learned about object-relational mapping and how it can simplify your code. But an ORM is not all unicorns and rainbows. This time we're are going to look at some of the downsides of using an ORM.
Disadvantages of ORM
Can be slower than direct DB access
As you might suspect, adding another layer to your database access can make your database reads and writes a bit slower than when accessing it directly.
The framework needs to map the class properties to the database columns and eventually create an SQL statement every time that data is loaded or saved. It's also possible that the ORM will create SQL behind the scenes that is not as optimized as what you could code by hand.
This can be mitigated somewhat by having the ORM cache your data. In this case, the ORM checks the cache before going to the database at all.
Increased Memory Usage
With an ORM, each row in each database table becomes an instance of a class when you access it. If you keep all these in memory as they are accessed, you can quickly start to use up a lot of memory. And if your ORM uses caching it will also use up a lot of memory to maintain the cache.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.