I had for the last month a bit of a problem with a quite basic datastore query. 
It involves 2 db.Models with one referring to the other with a 
db.ReferenceProperty.

The problem is that according to the admin logs the request takes about 2-4 
seconds to complete. I strip it down to a bare form and a list to display the 
results. 
The put works fine, but the get accumulates (in my opinion) way to much cpu 
time.

The get look like this:

outputData['items'] = {}
                
labelsData = Label.all()
                
for label in labelsData:
        labelItem = label.item.name
        if labelItem not in outputData['items']: 
                outputData['items'][labelItem] = { 'item' : labelItem, 'labels' 
: [] }
        outputData['items'][labelItem]['labels'].append(label.text)
        
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, outputData))


And the models:
class Item(db.Model):
        name = db.StringProperty()
        
class Label(db.Model):
        text = db.StringProperty()
        lang = db.StringProperty()
        item = db.ReferenceProperty(Item)

I've tried to make it a number of different way ie. instead of 
ReferenceProperty storing all Label keys in the Item Model as a db.ListProperty.

My test data is just 10 rows in Item and 40 in Label.

So my questions: Is it a fools errand to try to optimize this since the high 
cpu usage is due to the problems with the datastore or have I just screwed up 
somewhere in the code?

..fredrik



--
Fredrik Bonander
[email protected]
+46 70 943 5441

- the infinite power of the creative mind - 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to