sql - GAE Python NDB query fetch response time >55 seconds when only ~50 entities are present -
we have travel search website. search bus, execute query on bus operator entities. use gae python ndb. query fetch response time >55 seconds(on deployed version , not development server) when ~50 entities present.
presently query contains 5 items. if increase more five, response slows further considerably. please suggest ways bring down query time ~1 or 2 seconds or less possible.
please find relevant details below(sorry tried minimize below content extent):
query code:
start_time = datetime.datetime.now() qry_1 = x.query(ndb.and(x.active_status=="active", x.property_3==input_3, x.property_4==input_4, x.property_5==input_5, x.property_6.in(input_6_list), x.property_20.in(input_20_list))) record_list = qry_1.fetch() query_end_time = datetime.datetime.now() query_execution_time = query_end_time - start_time logging.info ("query_execution_time=["+str(query_execution_time)+"] ") # input_6_list contains ~5 string items # input_20_list contains ~5 string items
output in logs:
query_execution_time=[0:00:55.925250]
entity model:
class x(ndb.model): active_status = ndb.stringproperty() name = ndb.stringproperty() property_1 = ndb.stringproperty() property_2 = ndb.textproperty() property_3 = ndb.stringproperty() property_4 = ndb.stringproperty() property_5 = ndb.stringproperty() property_6 = ndb.stringproperty() property_7 = ndb.stringproperty() property_8 = ndb.stringproperty() property_9 = ndb.stringproperty(repeated=true) property_10 = ndb.stringproperty(repeated=true) property_11 = ndb.stringproperty() property_12 = ndb.structuredproperty(p) property_13 = ndb.structuredproperty(q) property_14 = ndb.stringproperty() property_15 = ndb.structuredproperty(r, repeated=true) property_16 = ndb.structuredproperty(s, repeated=true) property_17 = ndb.stringproperty() property_18 = ndb.stringproperty(repeated=true) property_19 = ndb.stringproperty() property_20 = ndb.stringproperty(repeated=true) property_21 = ndb.stringproperty(repeated=true) property_22 = ndb.structuredproperty(t, repeated=true) property_23 = ndb.integerproperty(default=6) property_24 = ndb.integerproperty(default=6) property_25 = ndb.integerproperty(default=6) property_26 = ndb.integerproperty(default=6) property_27 = ndb.integerproperty(default=6) property_28 = ndb.integerproperty(default=0) property_29 = ndb.integerproperty() date_added = ndb.datetimeproperty(auto_now_add=true) #creation date date_modified = ndb.datetimeproperty(auto_now=true) #update date property_30 = ndb.textproperty() property_31 = ndb.blobkeyproperty() property_32 = ndb.blobkeyproperty() property_33 = ndb.blobkeyproperty() property_34 = ndb.blobkeyproperty() property_35 = ndb.blobkeyproperty() property_36 = ndb.blobkeyproperty() property_37 = ndb.blobkeyproperty() property_38 = ndb.stringproperty() property_39 = ndb.blobkeyproperty() property_40 = ndb.stringproperty(default="not_allowed")
while debugging issue, ran appstats , had another question asked on
filtering on additional properties not expensive. using 'in' is. 2 in filters lists of 5 items each requires 25x concurrent seeks on backend.
could post index.yaml file code directory? if file not exist, query require multiple joins, explain slowness. run same query against dev_appserver , generate file automatically.
more here: https://developers.google.com/appengine/docs/python/config/indexconfig
by way, using 'indexed=false' on properties don't intend search on reduce cost puts considerably.
Comments
Post a Comment