python - GAE Appstats RPC Timeline graph shows long delays with complex NDB queries -


i have attached appstats production app search page below. page takes ~45 seconds load results ajax. there around 100 entities. query shown below:

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()   # input_6_list contains ~5 string items  # input_20_list contains ~5 string items  

i not able figure out:
why there empty spaces shown in graph below between rpc calls.. signify.. how can prevent them make website unusable
why query taking long complete

appstats timeline

the call trace points following line in code:

record_list = qry_1.fetch()  

call trace line showing it:

  <path[0]>/main.py:6332 post()  

the situation has not changed since your previous question. data looks relational. model such forces queries perform large numbers of index lookups satisfy , and in operations. in short, current model never scale. must restructured.

create new structure starting @ query - fastest (in other words simplest) way output required data minimum number of query parameters , index lookups? concatenate old query parameters (properties), hash result, , end single key in single index. fast. work backwards there storing records such every combination of properties hashes unique key , corresponding result record. must accept redundancy (storing same result multiple times different property combinations) nosql way, not third normal form.

there other potentially useful suggestions re-structuring data in these stackoverflow questions: storing song, artist , album data , how store document structure.

second answer: if inflexible on data model, replace datastore cloud sql because faster complex queries on small data sets.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -