Code

Opened 6 years ago

Closed 6 years ago

#7854 closed (wontfix)

get_list_or_404 slice performance

Reported by: Sanha Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: shortcuts, performance
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 ?

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 complicating get_list_or_404 for this situation.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.