First you need to change your model. In relation database you would have: db.define_table("articles", db.Field("title"), ...) db.define_table("comments", db.Field("article_id", db.articles), db.Field("author"), ...)
But with datastore you want to do the reverse, keep the comment ids in the article table: db.define_table("comments", db.Field("author"), ...) db.define_table("articles", db.Field("title"), db.Field("comments", "list:reference comments"), ...) or maybe even simply: db.define_table("articles", db.Field("title"), db.Field("comments", "list:integer"), ...) Then you read all the articles as usual: articles = db().select(db.articles.ALL) You go over all articles and store keys for all comments: from google.appengine.ext import db as gdb keys = [] for a in articles: keys.extend([gdb.Key.from_path("comments", id) for id in a.comments]) And finally you fetch all comments in a single query: comments = gdb.get(keys) You will get the comments in a fixed order so it shouldn't be difficult to map them to articles in the view. Simply for the first article where len(articles[0].comments) = 3, it would be comments[:3], for the second article where len(articles[1].comments) = 5, it would be comments[3:8]. A dictionary with article ids as you proposed would also work.