Answer the question
In order to leave comments, you need to log in
Reducing the number of reads in GAE. DS modeling question
Let's say there is a page displaying one article. The article has 4 tags. And there are two options for implementing this in the DataStore. The first is normal - the article refers to records in another table:
class Article(db.Model):
tags = db.ListProperty(db.Key)
The second, less flexible option - the article does not contain external links, but contains the names (strings) of tags in itself.
class Article(db.Model):
tags = db.StringListProperty()
An article is selected from the database simply: Article.get(key)
Question . Is it possible to say that a page request will cause 5 reads in the first case, and only one in the second? (Reads are those that count against quota control.)
Answer the question
In order to leave comments, you need to log in
How to profile an application:
import os
# ...
if os.getenv('SERVER_SOFTWARE', '').startswith('Dev'):
# http://localhost:8080/_ah/stats/ - тут появится подробная статистика: запросы, время, вызовы api
from google.appengine.ext.appstats import recording
app = recording.appstats_wsgi_middleware(app)
class Artwork(db.Model):
refs = db.ListProperty(db.Key)
@property
def taxonomy(self):
return db.get(self.refs)
# 100 вызовов
for tag in tags: db.put(Tag(tag))
# 1 вызов
db.put([Tag(tag) for tag in tags])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question