db.get(<10 keys>) vs. ModelType.all().filter(...).fetch(10)

4 views
Skip to first unread message

Blixt

unread,
Jul 19, 2010, 2:26:19 PM7/19/10
to Google App Engine
I'd like to know the performance difference between db.get()ting with
specific keys and getting the same entities using a filter.

I did a benchmark and using a query appears to be very slightly
faster. Are there situations where the performance can differ more?
Are there other pitfalls I should watch out for?

Nick Johnson (Google)

unread,
Jul 20, 2010, 9:00:17 AM7/20/10
to google-a...@googlegroups.com
Hi Blixt,

Since a query consists of an index scan followed by a batch get, internally, the batch get alone should always be faster. One possible exception is if you're doing a query that is satisfiable by the primary index - for example, querying on a key range, or only by kind with no filters. In these cases, performance is likely to be about the same, possibly slightly better for the query.

-Nick Johnson


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




--
Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047

Blixt

unread,
Jul 20, 2010, 9:02:23 AM7/20/10
to Google App Engine
Okay, thanks! Just what I wanted to hear. I guess my benchmark results
were due to randomness then.

/Blixt

On Jul 20, 3:00 pm, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:
> Hi Blixt,
>
> Since a query consists of an index scan followed by a batch get, internally,
> the batch get alone should always be faster. One possible exception is if
> you're doing a query that is satisfiable by the primary index - for example,
> querying on a key range, or only by kind with no filters. In these cases,
> performance is likely to be about the same, possibly slightly better for the
> query.
>
> -Nick Johnson
>
>
>
>
>
> On Mon, Jul 19, 2010 at 7:26 PM, Blixt <andreasbl...@gmail.com> wrote:
> > I'd like to know the performance difference between db.get()ting with
> > specific keys and getting the same entities using a filter.
>
> > I did a benchmark and using a query appears to be very slightly
> > faster. Are there situations where the performance can differ more?
> > Are there other pitfalls I should watch out for?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-a...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages