The decrease in the number of s read in GAE. Question on modelling DS

Let's have a page displaying a single article. The article has a 4 tag. And there are two options for implementing this in the DataStore. The first normal — the article references a record in another table:

the <pre>class Article(db.Model): tags = db.ListProperty(db.Key)</pre>

The second option is less flexible — the article contains no links to the outside, but contains the names (strings) of tags in yourself.

the <pre>class Article(db.Model): tags = db.StringListProperty()</pre>

An article extracted from the database just Article.get(key)

Question. If you can say that a page request will cause in the first case, 5 read operations, while the second — just one? (Reading — those who are ignored by the quota control.)
October 8th 19 at 01:12
1 answer
October 8th 19 at 01:14
How to profile the application:
import os

# ...

if os.getenv('SERVER_SOFTWARE', ").startswith('Dev'):
 # http://localhost:8080/_ah/stats/ - there will be detailed statistics: requests, time, api calls
 from google.appengine.ext.appstats import recording
 app = recording.appstats_wsgi_middleware(app)

In the first case, you can do two calls (0 if caching of the sample in gae memcache):
class Artwork(db.Model):
 refs = db.ListProperty(db.Key)
 def taxonomy(self):
 return db.get(self.refs)

You can reduce the number of calls passing in the db.get and db.put multiple values
# 100 call
for tag in tags: db.put(Tag(tag))

# 1 call
db.put([Tag(tag) for tag in tags])

In the second case will be only one RPC call, maybe store the string (0 if the caching).

Well, it is necessary to cache a sample in the gae memcache, maybe it's faster and there queries are not considered.

PS Nick's Blog — ReferenceProperty prefetching in App Engine — great game from nick Johnson
Thanks for the link. Nick and Guido seems like the only people who understand the game :)

Okay, there is a group get/put, but if you feed them 5 objects, how much will be deducted from the daily quota is 5 transactions or one? - misae commented on October 8th 19 at 01:17
If get, one. If put, the same one, but the more CPU time will be spent. So when bulkload easily in just a few seconds of real time to spend several hours of CPU (~60k records). - Kirstin.Corkery commented on October 8th 19 at 01:20
But no. Lie. Here there are fresh and accurate data. get 1 read operation on the entity. A total of 5 operations.
RPC == API == the high-level steps. A quota (50k operations) low level.

Sketched test application checked. All the way. - Kirstin.Corkery commented on October 8th 19 at 01:23
Do not tell the number of low-level operations somehow monitored? - misae commented on October 8th 19 at 01:26
In appstats there. Only API. Can only roughly estimate how many calls need page.
And in the combat environment detailed statistics will be in the Quota Details. The total number of operations: quota read/write + detailed specification of operations. - Kirstin.Corkery commented on October 8th 19 at 01:29

Find more questions by tags Search engine optimizationPythonG Suite