>
> it takes really long to process by MySQL.
>

Which version? Subquery performance gets better in MySQL 5.6 and even more
so on MariaDB.

 for count the query would be really simple, and wouldn't need the
> prefetches.
>

When counting, prefetches aren't actaully executed. Check the actual SQL
with e.g. django-debug-toolbar .

On Fri, 29 Jun 2018 at 21:24, Jakub Kleň <kuk...@gmail.com> wrote:

> Hi guys, I came across a problem today while testing my webapp with a full
> migrations applied from my legacy site for the first time.
> The problem is I'm using Prefetch in my view query (get_queryset), and it
> works fine when I just fetch it, but the problem comes with the .count()
> query which generates sql with subqueries, and it takes really long to
> process by MySQL.
> The nicest solution I'm thinking about would be to use 2 different queries
> for object_list / pagination count, because for count the query would be
> really simple, and wouldn't need the prefetches.
> I think this scenario may be pretty likely to come across also for other
> Django users, so I'm thinking if it wouldn't be nice to have it directly in
> Django.
> From my point of view, it seems like the implementation would be pretty
> straightforward and easy, and I would even like to look into it and
> contribute to the Django project if possible and if you think it would be
> useful.
> I would like to add count_queryset param to Paginator.__init__, and def
> get_count_queryset to MultipleObjectMixin. Happy to hear your opinions on
> this :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/a29e6b81-f05c-46af-a479-04e1f4bce705%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/a29e6b81-f05c-46af-a479-04e1f4bce705%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM1zPun1epd8G7BpV5z-bWXAq-rMkvmZvwgLGqsTzadGFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to