Reputation: 2789
Which is more CPU efficient, 1, 2 or 3?
key = something.key()
id = something.key().id()
1) db.GqlQuery("select.....").fetch(1)[0]
2) db.get(key)
3) get_by_id(id)
Upvotes: 0
Views: 198
Reputation: 101149
Option 1 is less efficient, because it requires a query. Incidentally, note that if you want exactly one result, you can call get()
on the Query, which will return the first result, or None if there are none.
2 and 3 are identical; get_by_id
is just syntactic sugar for constructing a key and fetching it with get
.
Upvotes: 5