What are the performance implications of polymodels versus normal Bigtable models in Google App Engine

bigtablegoogle-app-engineperformance

What produces the best performance in regular Google App Engine use, a polymodel or a normal "Bigtable" model?

The polymodel, effectively, creates a column in the parent table called "class" which provides the inheritance tracking. Whereas a normal Bigtable, inherited from a parent class, creates a new and separate data structure, without the ability to query the parent and find all children of all subtyped classes.

Best Answer

There probably is a performance difference, but it's probably pretty small.

Here's what I found (all based on the the Google Docs for Python).

  1. BigTable does not support PolyModel information natively. Instead, it's implemented using a 'class' property. So, when you try to perform a search, for example, to find a base class, you will be searching on this 'class' property.

  2. All queries that use the PolyModel class have an extra filter applied that filters by the given class (using the 'class' property).

  3. Any indexes created for a PolyModel class, must take into account the extra 'class' column.

Essentially, the PolyModel class takes care of the 'class' property on its own, inserting it into queries and utilizing for other queries. Other than that, it works identical to standard BigTable usage.

So, the difference is really just adding and maintaining one extra column.

Is there a performance difference? Yes, probably so. Every column you add to any database system is going to have a performance impact. But, is it significant? Probably not.