Opened 7 months ago

Last modified 7 months ago

#35596 assigned Bug

Database access optimization warning that get() can retrieve hundreds or thousands of records is outdated

Reported by: Francisco Couzo Owned by: Ripoohann S Kumar
Component: Documentation Version:
Severity: Normal Keywords:
Cc: Francisco Couzo Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no
Pull Requests:How to create a pull request

Description

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.

This was modified 5 years ago in commit 330638b89f14e1fb06e9d313ccc9768ae167c53f

There is one specific case when get() can return all the result set, which is when using the oracle db and select_for_update

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (2)

comment:1 by Ripoohann S Kumar, 7 months ago

Owner: set to Ripoohann S Kumar
Status: newassigned

comment:2 by Sarah Boyce, 7 months ago

Summary: Database access optimization page has outdated infoDatabase access optimization warning that get() can retrieve hundreds or thousands of records is outdated
Triage Stage: UnreviewedAccepted

A docs link for reference: https://docs.djangoproject.com/en/5.0/topics/db/optimization/#retrieve-individual-objects-using-a-unique-indexed-column

Agreed an update here would be nice, thank you for the report 👍 refs #6785

Note: See TracTickets for help on using tickets.
Back to Top