Closed Bug 1148896 Opened 9 years ago Closed 9 years ago

Use values_list queryset to lower amount of queries

Categories

(developer.mozilla.org Graveyard :: Code Cleanup, defect)

All
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jezdez, Assigned: jezdez)

Details

(Whiteboard: [specification][type:bug])

What did you do?
================
I found lots of code like this:

  spams = [foo.spam for foo in Egg.objects.all()]

This can be written like which reduces Python load:

  spams = Egg.objects.values_list('spam', flat=True)


What happened?
==============
I guffawed.

What should have happened?
==========================
I should sing tralalalalaalala

Is there anything else we should know?
======================================
Component: General → Code Cleanup
Assignee: nobody → jezdez
Status: NEW → ASSIGNED
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/105ca04c03e92d28204fdd1c0025b3a6413bb8d2
Bug 1148896 - Add own superuser_required decorator.

https://github.com/mozilla/kuma/commit/946d25bb17da8bffe7963453756c4c61a3b104b9
Fix bug 1148896 - Stop using bad db query patterns.

That includes getting a list of single column values from the database
as well as some other issues.

https://github.com/mozilla/kuma/commit/8fabccd62739c0a7fb272a465070caeab7f8cfee
Bug 1148896 - Use more Django shortcuts.

https://github.com/mozilla/kuma/commit/1a30144594442cc4291a070f62de8780d9d7016c
Bug 1148896 - Apply more code best practices.

https://github.com/mozilla/kuma/commit/f8b9f86de4206b84eadc007d219fdc08adb72220
Merge pull request #3148 from mozilla/bug1148896

Code cleanups and best practices applied.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.