views:

80

answers:

2

From what I've understood, App Engine indexes are costly both in terms of increased overall storage size and by slowing down your writes.

But do indexes only cost when they're actually used in queries and are explicitly defined in index.yaml? Or do properties such as StringProperty cost more than their non-indexed counterpart (e.g. TextProperty) simply by existing, even though they're not used in index.yaml?

+3  A: 

There are built-in/default indices which would contribute overhead even if you don't explicitly define any additional indices in your index.yaml file. Thus you should use TextProperty instead of StringProperty for a field if you know you will never need to filter on that field.

Details on these implicit indices are provided by the article How Entities and Indices are Stored.

David Underhill
+4  A: 

You could also set indexed=False for properties which you don't want indexed:

http://code.google.com/appengine/docs/python/datastore/propertyclass.html#Property

Saxon Druce
How to disable indexing on a property in case of Java code (JDO)?
akirekadu
@akirekadu: I haven't used Java on app engine, but http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Introducing_Indexes says to use "gae.unindexed".
Saxon Druce
Thanks. I ended up using low level APIs for this http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Entity.html#isUnindexedProperty(java.lang.String)The method suggested in the documentation you pointed at is certainly simpler and elegant.
akirekadu