---
source: https://iinventedlight.com/library/notes/django-defer-only.md
title: "Defer or load only some Django fields, and when a covering index helps"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Django docs); Public-Domain (SQLite); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Django docs, QuerySet API reference; SQLite, Query Planning. BSD-3-Clause; Public-Domain."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: Django defer/only and SQLite covering indexes"
tags: [django, defer, only, queryset, sqlite, index]
client: Librarian
sources:
  - id: S1
    title: "QuerySet API reference"
    publisher: Django docs
    url: https://docs.djangoproject.com/en/5.2/ref/models/querysets/
    accessed: 2026-11-19
    license: "BSD-3-Clause"
  - id: S2
    title: "Query Planning"
    publisher: SQLite
    url: https://www.sqlite.org/queryplanner.html
    accessed: 2026-11-19
    license: "Public-Domain"
---
# Defer or load only some Django fields, and when a covering index helps
**Answer:** If a model has fields you may not need when you initially fetch the data, `defer()` tells Django not to retrieve them from the database. `only()` is essentially the opposite of `defer()`. The fields passed into this method are loaded immediately when the queryset is evaluated, unless they are already specified as deferred.

## defer() and only()

A queryset that has deferred fields will still return model instances. Accessing a deferred field retrieves it from the database. You can never defer the loading of the primary key. Pass `None` to `defer()` if you want to clear the set of deferred fields. If almost all the fields need to be deferred, `only()` can be simpler.

## Covering indexes

When the query only needs those selected columns, a covering index can make the SQL cheaper. A covering index contains all the columns of the original table that are used by the query, both the search terms and the output. With a covering index, SQLite never needs to consult the original table. A covering index contains all the columns of the original table that are used by the query.

| defer() | only() |
|---|---|
| defer() | Do not retrieve named fields from the database |
| only() | Opposite of defer(); listed fields are loaded immediately |
| primary key | You can never defer loading it |
| covering index | Index that holds search terms and output columns |

## See also

- [django-querysets](https://iinventedlight.com/library/notes/django-querysets/)
- [django-models](https://iinventedlight.com/library/notes/django-models/)
- [sqlite-query-planner-indexes](https://iinventedlight.com/library/notes/sqlite-query-planner-indexes/)

## Claims

- id: C1
  claim: defer() tells Django not to retrieve named fields from the database until they are accessed.
  source: S1
  evidence: "you can tell Django not to retrieve them from the database"

- id: C2
  claim: only() is the opposite of defer() and loads the fields passed into the method.
  source: S1
  evidence: "The only() method is essentially the opposite of defer()"

- id: C3
  claim: A SQLite covering index can satisfy a query without consulting the original table.
  source: S2
  evidence: "SQLite never needs to consult the original table"

## Sources

- [S1] QuerySet API reference. Django docs. https://docs.djangoproject.com/en/5.2/ref/models/querysets/ . License: BSD-3-Clause. Accessed 2026-11-19.

- [S2] Query Planning. SQLite. https://www.sqlite.org/queryplanner.html . License: Public-Domain. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Django docs, QuerySet API reference; SQLite, Query Planning. BSD-3-Clause; Public-Domain. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
