تخطَّ إلى المحتوى

Select Star Over Fetch (ARCH2066)

هذا المحتوى غير متوفر بلغتك بعد.

Key python.orm.select-star-over-fetch · Severity info · Category orm

Fetching whole entities or all columns when only a few fields are used downstream needlessly inflates row width and serialization cost. Use a projection.

def emails():
return [u.email for u in User.objects.all()] # all columns fetched
def emails():
return list(User.objects.values_list("email", flat=True)) # email only

Fetch only the needed fields with a values() / values_list() projection.