andrewebdev / django-adzone

A django application to manage advertising and advertising zones.
BSD 3-Clause "New" or "Revised" License
87 stars 39 forks source link

Reduce number of queries required per adzone tag. #19

Closed melinath closed 11 years ago

melinath commented 11 years ago

Right now, using {% random_zone_ad %} or {% random_category_ad %} adds three queries to the page: one for the AdBase instance, one to check whether a TextAd instance exists, and one to check whether a BannerAd instance exists.

By adding a .select_related() call to AdManager.get_random_ad(), we can reduce the number of queries down to one.