How many indexes are created for entity with 50 indexed properties when only single property queries are executed in GAE NDB Python

StackOverflow https://stackoverflow.com/questions/22742101

سؤال

How many indexes are created for entity with 50 indexed properties when only single property queries are executed in GAE NDB Python. There are no repeated properties

class X(ndb.Model): 
    p1 = ndb.KeyProperty(indexed=False) 

    p2 = ndb.StringProperty(indexed=True) 
    p3 = ndb.StringProperty(indexed=True) 
    :: 
    p51 = ndb.StringProperty(indexed=True) 

my query structure(all queries would be only single property queries without AND, OR, IN):

q = X.query(X.pn==data)  # pn could be p2, p3, .., p51 
record_list, next_curs, more = q.fetch_page(15)  

How many indexes would be needed for such queries(it would be great if you show the calculation step too)

Would all these indexes be autogenerated

Would it be a better idea to put these indexes myself in the index.yaml file

I would have 75,000,000 (75 million) entities of the above model. Does the number of entities affect the total number of indexes for a model

Would I hit the default limit on indexes or composite indexes(if any composite index would be needed for above entity or query)

Would there be any change in the above answers if i add sort order based on one of three properties(say, p2 or p3 or p4)

I have referred the following link but could not understand it properly
https://developers.google.com/appengine/articles/indexselection

هل كانت مفيدة؟

المحلول

You will have 51 indexes: one for an entity kind and one for each indexed property. These indexes are generated automatically.

If you need to create queries on multiple properties, you will need additional custom indexes.

The number of indexes does not depend on the number of entities.

At 75m entities you will need a lot of storage space. Also, your writing costs will be very high as every change to an entity will trigger updates in all indexes.

I can hardly imagine a use case for an entity with 50 indexed properties.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top