Skip to content

Commit 92f3959

Browse files
committed
adding one more seciton on ORMs
1 parent 9a42375 commit 92f3959

4 files changed

Lines changed: 59 additions & 4 deletions

File tree

‎all.html‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,6 @@ <h2>What are the downsides of using an ORM?</h2>
33373337
<p>There are numerous downsides of ORMs, including</p>
33383338
<ol>
33393339
<li>impedance mismatch</li>
3340-
<li>difficulty expressing complex queries</li>
33413340
<li>potential for reduced performance</li>
33423341
<li>shifting complexity into the application from the database layer</li>
33433342
</ol>
@@ -3347,6 +3346,24 @@ <h3>Impedance mismatch</h3>
33473346
moving data between relational tables and application objects. The gist
33483347
is that the way a developer uses objects is different from how data is
33493348
stored and joined in relational tables.</p>
3349+
<h3>Potential for reduced performance</h3>
3350+
<p>One of the concerns that's associated with any higher-level abstraction or
3351+
framework is potential for reduced performance. With ORMs, the performance
3352+
hit comes from the translation of application code into a corresponding SQL
3353+
statement which may not be tuned properly. </p>
3354+
<p>ORMs are also often easy to try but difficult to master. For example, a
3355+
beginner using Django might not know about the
3356+
<a href="https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related"><code>select_related()</code> function</a>
3357+
or how that can dramatically improve some queries' performance with
3358+
foreign key relationships. There are dozens of performance tips and tricks
3359+
for every ORM and it's possible that investing time in learning those
3360+
quirks may be better spent just learning SQL and how to write stored
3361+
procedures.</p>
3362+
<p>There's a lot of hand-waving "may or may not" and "potential for" in this
3363+
section. In most cases ORMs are good enough for roughly 80-90% of use cases
3364+
and in 10-20% of database interactions there can be major performance
3365+
improvements by having a knowledgeable database adminstrator write tuned
3366+
SQL statements to replace the ORM's generated SQL code.</p>
33503367
<h2>Django's ORM</h2>
33513368
<p>The <a href="/django.html">Django</a> web framework comes with
33523369
its own built-in object-relational mapping module, generally referred to

‎feeds/all.atom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2015-06-14T18:56:30Z</updated></feed>
2+
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2015-06-16T08:37:56Z</updated></feed>

‎object-relational-mappers-orms.html‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ <h2>What are the downsides of using an ORM?</h2>
9797
<p>There are numerous downsides of ORMs, including</p>
9898
<ol>
9999
<li>impedance mismatch</li>
100-
<li>difficulty expressing complex queries</li>
101100
<li>potential for reduced performance</li>
102101
<li>shifting complexity into the application from the database layer</li>
103102
</ol>
@@ -107,6 +106,24 @@ <h3>Impedance mismatch</h3>
107106
moving data between relational tables and application objects. The gist
108107
is that the way a developer uses objects is different from how data is
109108
stored and joined in relational tables.</p>
109+
<h3>Potential for reduced performance</h3>
110+
<p>One of the concerns that's associated with any higher-level abstraction or
111+
framework is potential for reduced performance. With ORMs, the performance
112+
hit comes from the translation of application code into a corresponding SQL
113+
statement which may not be tuned properly. </p>
114+
<p>ORMs are also often easy to try but difficult to master. For example, a
115+
beginner using Django might not know about the
116+
<a href="https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related"><code>select_related()</code> function</a>
117+
or how that can dramatically improve some queries' performance with
118+
foreign key relationships. There are dozens of performance tips and tricks
119+
for every ORM and it's possible that investing time in learning those
120+
quirks may be better spent just learning SQL and how to write stored
121+
procedures.</p>
122+
<p>There's a lot of hand-waving "may or may not" and "potential for" in this
123+
section. In most cases ORMs are good enough for roughly 80-90% of use cases
124+
and in 10-20% of database interactions there can be major performance
125+
improvements by having a knowledgeable database adminstrator write tuned
126+
SQL statements to replace the ORM's generated SQL code.</p>
110127
<h2>Django's ORM</h2>
111128
<p>The <a href="/django.html">Django</a> web framework comes with
112129
its own built-in object-relational mapping module, generally referred to

‎source/content/pages/05-data/04-object-relational-mappers.markdown‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ a data analysis tool or a batch script without a user interface.
7979
There are numerous downsides of ORMs, including
8080

8181
1. impedance mismatch
82-
1. difficulty expressing complex queries
8382
1. potential for reduced performance
8483
1. shifting complexity into the application from the database layer
8584

@@ -92,6 +91,28 @@ is that the way a developer uses objects is different from how data is
9291
stored and joined in relational tables.
9392

9493

94+
### Potential for reduced performance
95+
One of the concerns that's associated with any higher-level abstraction or
96+
framework is potential for reduced performance. With ORMs, the performance
97+
hit comes from the translation of application code into a corresponding SQL
98+
statement which may not be tuned properly.
99+
100+
ORMs are also often easy to try but difficult to master. For example, a
101+
beginner using Django might not know about the
102+
[`select_related()` function](https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related)
103+
or how that can dramatically improve some queries' performance with
104+
foreign key relationships. There are dozens of performance tips and tricks
105+
for every ORM and it's possible that investing time in learning those
106+
quirks may be better spent just learning SQL and how to write stored
107+
procedures.
108+
109+
There's a lot of hand-waving "may or may not" and "potential for" in this
110+
section. In most cases ORMs are good enough for roughly 80-90% of use cases
111+
and in 10-20% of database interactions there can be major performance
112+
improvements by having a knowledgeable database adminstrator write tuned
113+
SQL statements to replace the ORM's generated SQL code.
114+
115+
95116

96117
## Django's ORM
97118
The [Django](/django.html) web framework comes with

0 commit comments

Comments
 (0)