#28459: Improve performance of QuerySet -------------------------------------+------------------------------------- Reporter: Sergey Fedoseev | Owner: nobody Type: | Status: closed Cleanup/optimization | Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: fixed Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Sergey Fedoseev): [https://github.com/django/django/pull/8849 PR (Improved performance of SQLCompiler.results_iter())] Before: {{{ In [3]: %timeit for x in City.objects.values_list('id'): pass 74 ms ± 1.45 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) In [2]: %timeit for x in City.objects.annotate(v=models.Value(1, output_field=models.IntegerField())).values_list('v'): pass 343 ms ± 2.62 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) }}} After: {{{ In [4]: %timeit for x in City.objects.values_list('id'): pass 69.1 ms ± 744 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) In [3]: %timeit for x in City.objects.annotate(v=models.Value(1, output_field=models.IntegerField())).values_list('v'): pass 254 ms ± 1.61 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/28459#comment:5> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.67408e938b28f011cea3e6fcfd8959e7%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.