diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2010-09-13 05:08:17 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2010-09-13 05:08:17 +0000 |
| commit | 767cf13d7654b92ce398bb142a908b3e0c461564 (patch) | |
| tree | e1486e237ef390e1f0cf3a597f323a15446e8647 /docs/topics/db/optimization.txt | |
| parent | 17a79d503302f3aad5e2439d858d6e3cbba102e4 (diff) | |
The optimization docs were a little too enthusiastic in recommending
defer() and only() usage. Disk access patterns affect when this is a
good idea, so this patch adds a note about the trade-offs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13820 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/db/optimization.txt')
| -rw-r--r-- | docs/topics/db/optimization.txt | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/topics/db/optimization.txt b/docs/topics/db/optimization.txt index baf8cfa268..c3b30074ca 100644 --- a/docs/topics/db/optimization.txt +++ b/docs/topics/db/optimization.txt @@ -171,6 +171,8 @@ know that you won't need (or won't need in most cases) to avoid loading them. Note that if you *do* use them, the ORM will have to go and get them in a separate query, making this a pessimization if you use it inappropriately. +Also, be aware that there is some (small extra) overhead incurred inside Django when constructing a model with deferred fields. Don't be too aggressive in deferring fields without profiling as the database has to read most of the non-text, non-VARCHAR data from the disk for a single row in the results, even if it ends up only using a few columns. The `defer()` and `only()` methods are most useful when you can avoid loading a lot of text data or for fields that might take a lot of processing to convert back to Python. As always, profile first, then optimize. + Use QuerySet.count() -------------------- |
