kennysong
kennysong

Reputation: 2134

Size/cost of query in GAE datastore

If I have a query that's structured like this:

q = Questions.all()
q.order('-votes')
results = q.run(limit=25)

And votes is just an IntegerProperty in a Questions db model, does the size/cost (basically what counts towards my quota) of the query depend on the number of entities?

Basically, if I'm trying to order 1000 Questions, is it more expensive than ordering only 10 Questions?

Upvotes: 2

Views: 130

Answers (1)

dragonx
dragonx

Reputation: 15143

short answer: No.

There are read costs and write costs.

Write costs occur when you write an entity, and the big influence is the number of indexed properties per entity.

Read costs are based on the number of entities returned in a query.

If you sort on votes, you need to make sure the votes property is indexed. That's 1-2 additional writes per entity written.

Read costs vary by the number of entities returned. The filter and sort order don't affect the cost on read.

Upvotes: 4

Related Questions