ambitioninc/django-entity — pull request #40 by wesleykendall (2014-08-23 15:23:04+00:00)
Title: Performance optimations for caching entity relationships and doing is_sub_to_all calls

@Wilduck I added a couple of simple optimizations to django entity that provide large performance increases.

The first optimization is in the is_sub_to_all call. Previously we had to do a count query for all is_sub_to_all calls to verify that entitys were part of all relationships. However, in the case of just one super entity, the query is extremely simple. I checked for this case.

The second optimization is in the cache_relationships call, and it allows users to specifically ignore caching sub or super entity relationships. Previously it cached all of them. In django 1.7, we will be able to optimize this call even more by allowing users to ignore fetching entity meta in the prefetch call. While this could have been accomplished with raw SQL or by doing the join in memory, the amount of work to do this will shortly be negated with the next release of Django