On Mon, Mar 22, 2010 at 1:44 PM, Aleksandr Vladimirskiy <
[email protected]> wrote:

> Making the Product Variations Manager paged didn't appear to help, at least
> in my case.
>
> I think it's because the real cause for large database queries is the
> get_subtypes method call of the Product model. That call looks through every
> Product and tries to access related ConfigurableProduct, Product Variation,
> Gift Certificate or any other product sub type and if it doesn't fail it
> adds the subtype model to the list of subtypes. So even if you're just
> trying to get a list of Products with Configurable Product subtype, the way
> the Product Variations Manager does, you get to make the Django ORM look at
> every single product subtype instance times the number of product subtypes
> you have.
>
> At this point I'm still mulling over how to make Product.get_subtypes()
> more efficient. But if you just want to make the Product Variations Manager
> view load way faster you can replace the following:
>
> products = [p for p in Product.objects.all() if "ConfigurableProduct" in
> p.get_subtypes()]
>
> with:
>
> products = Product.objects.filter(configurableproduct__in =
> ConfigurableProduct.objects.all())
>
> We went from ~17,000 database queries to ~400.
>
>

 That's a good start. 400 queries still isn't optimal but that's a heck of a
lot better. If you wouldn't mind putting in a ticket, we'll update tip to
make this improvement.

-Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to