home App Engine lifted limit for query results   

Google just lifted the restriction that App Engine’s data store query can only return 1000 results at a time.

I just updated this blog (built on App Engine) to take advantage of this functionality. It nicely simplifies some things. For example, before I had to write contorted code like the one below to get all Articles:

def get_all_articles():
    query = Article.gql('ORDER BY __key__')
    articles = []
    while True:
        got = query.fetch(201)
        for article in got[:200]:
            articles.append(a)
        if len(got) <= 200:
            break
        query = Article.gql('WHERE __key__ > :1 ORDER BY __key__', got[199].key())
    return articles

Now it’s much simpler:

def get_all_articles():
    query = Article.all()
    articles = []
    for article in query:
        articles.append(a)
    return articles

Another improvement they did is support for query cursors, which allow bookmarking a position in the query. It makes implementing pagination of results easier.

It’s nice to program against a platform that improves.

← newer • 36 of 636older →