mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-19 02:48:16 +08:00
decoding values_list on a picklefield turns out to be 10 times faster than using list_comprehension
This commit is contained in:
@@ -8,6 +8,7 @@ from django.db.models.signals import pre_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone
|
||||
from picklefield import PickledObjectField
|
||||
from picklefield.fields import dbsafe_decode
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
@@ -32,8 +33,9 @@ class Task(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def get_result_group(group_id):
|
||||
# values_list() doesn't work here cause it returns encoded fields
|
||||
return [t.result for t in Task.get_task_group(group_id)]
|
||||
# values + decode is 10 times faster than just list comprehension
|
||||
values = Task.objects.filter(group=group_id).values_list('result', flat=True)
|
||||
return [dbsafe_decode(t) for t in values]
|
||||
|
||||
@staticmethod
|
||||
def get_task(task_id):
|
||||
|
||||
Reference in New Issue
Block a user