From 525e51f6ce7d77012b60a9bdbd098322f94bdd3f Mon Sep 17 00:00:00 2001 From: CodeQuiver <38484031+CodeQuiver@users.noreply.github.com> Date: Mon, 18 May 2026 17:26:31 -0700 Subject: [PATCH] Fixed #35596 -- Removed mention of unlimited results from QuerySet.get(). Obsolete since 330638b89f14e1fb06e9d313ccc9768ae167c53f. --- docs/topics/db/optimization.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/topics/db/optimization.txt b/docs/topics/db/optimization.txt index 9c4ba314ae75..ed990a123f24 100644 --- a/docs/topics/db/optimization.txt +++ b/docs/topics/db/optimization.txt @@ -189,12 +189,10 @@ Doing the following is potentially quite slow: First of all, ``headline`` is not indexed, which will make the underlying database fetch slower. -Second, the lookup doesn't guarantee that only one object will be returned. -If the query matches more than one object, it will retrieve and transfer all of -them from the database. This penalty could be substantial if hundreds or -thousands of records are returned. The penalty will be compounded if the -database lives on a separate server, where network overhead and latency also -play a factor. +Second, the lookup may return multiple results. Even though Django applies a +limit of 21 objects when using :meth:`~django.db.models.query.QuerySet.get`, +the database may still need to scan everything to evaluate a non-unique +condition. Narrowing your query up-front is more efficient. Retrieve related objects efficiently ====================================