Jacob Kaplan-Moss

Tag: inheritance

Django gotcha: concrete inheritance November 2nd, 2010

Since 1.0, Django’s supported model inheritance. It’s a neat feature, and can go a long way towards increasing flexibility in your modeling options. However, model inheritance also offers a really excellent opportunity to shoot yourself in the foot: concrete (multi-table) inheritance. If you’re using concrete inheritance, Django creates implicit joins back to the parent table on nearly every query. This can completely devastate your database’s performance. To refresh, if you’ve got models like:…