Search code examples
google-app-engineindexinglimitlistproperty

How Do List Properties Impact the Index Entries per Entity in Google App Engine?


I know that there is a limit of 5000 index entries per entity, which means I can't do things like this:

class Foo(db.Model):
   x = db.ListProperty(int)
   y = db.ListProperty(int)

foo1 = Foo(x = range(5001))
foo1.put()

Furthermore, if I have the index in index.yaml

- kind: Foo
 properties:
 - name: x
 - name: y

then I also see from this thread:

http://groups.google.com/group/google-appengine/browse_thread/thread/d5f4dcb7d00ed4c6

that I can't do this:

foo2 = Foo(x = range(100), y=range(100))
foo2.put()

because that would give me 10,000 index entries.

However, my question is: if I DON'T have any entries in index.yaml for Foo and try:

foo3 = Foo(x = range(100), y=range(100))
foo3.put()

will that still raise the "BadRequestError:Too many indexed properties for entity" exception? From my tests, it looks like it won't cause any errors. Is this correct? How many index entries would foo3 have in this case? Is it 200 (the sum of the lengths of each list)? Or something else?


Solution

  • You're correct - this won't raise any exceptions, and it will create 200 index entries.

    The way this works for composite indexes is that one index row is created per unique combination of values, whilst built-in indexes create one index row per value - they're equivalent to having a separate single-property index defined on every property in your model.