Opened 16 years ago
Closed 16 years ago
#7854 closed (wontfix)
get_list_or_404 slice performance
Reported by: | Sanha | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | shortcuts, performance | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
in this case,
Foo.objects.filter(name__startswith="peter")[:10]
Performance is optimized by SQL.
but in this case,
get_list_or_404(Foo, name__startswith="peter")[:10]
This slice is done by Python.
This is proformance issue.
Is it possible shortcuts can do slice by SQL ?
Note:
See TracTickets
for help on using tickets.
The
get_list_or_404
method is shortcut for simple filters. If you want more complex querysets and if slicing in Python isn't acceptable for your particular use-case, then just do it by hand. It's not worth complicatingget_list_or_404
for this situation.