[google-appengine] Re: Are key filters more efficient than ancestor queries?

2011-09-30 Thread Eric Gustavson
Hi,

In light of Google's pricing changes, I would like to re-open Blixt's 
original question, but instead of in terms of performance, I would like to 
know the answer in terms of price. This FAQ 
answerdescribes
 how different datastore operations are priced.

Which is cheaper, a fetch by ancestor or via a ReferenceProperty?

Also, why should one avoid using the parent/ancestor relationship if they 
don't need transactions?

Let me know if my questions need clarifications.

Thanks!

--Eric


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/Z0qsX-PdojMJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Re: Are key filters more efficient than ancestor queries?

2010-07-19 Thread Vladimir Prudnikov
Also keep in mind that you can't change parent property after you create an
object.

On 19 July 2010 13:26, Blixt  wrote:

> Thanks Nick.
>
> The reason I use entity groups is not for any kind of performance
> reasons – I really need to make sure that the Parent entity is updated
> in combination with a Child entity being added, and the values being
> set are related to the order of entity insertions, so entity groups
> feel like the right thing to do to ensure data atomicity.
>
> My only thought is that I'd rather add redundancy (by adding a
> ReferenceProperty that can be inferred from the key) than lose
> performance. If the performance difference is negligible however, I'd
> rather not add an unnecessary property.
>
> /Blixt
>
> On Jul 19, 1:21 pm, "Nick Johnson (Google)" 
> wrote:
> > Hi Blixt,
> >
> >
> >
> >
> >
> > On Mon, Jul 19, 2010 at 12:15 PM, Blixt  wrote:
> > > Imagine the following models:
> >
> > > class Parent(db.Model):
> > >name = db.StringProperty()
> > >count = db.IntegerProperty()
> >
> > > class Child(db.Model):
> > >number = db.IntegerProperty()
> > >value = db.StringProperty()
> >
> > > Whenever a new Child is added, it is added with a Parent as its parent
> > > entity in a transaction which also updates some values on the Parent.
> >
> > > My question is this: To get a list of children that belongs to a
> > > Parent, is it more efficient to add a ReferenceProperty to the Child
> > > model and filter by that, than it is to use the ancestor filter in
> > > queries?
> >
> > > To clarify in code:
> >
> > > # Using ancestor
> > > Child.all().ancestor(parent_key).fetch(10)
> > > # Using filter on a new ReferenceProperty called 'my_parent'
> > > Child.all().filter('my_parent', parent_key).fetch(10)
> >
> > These two should have roughly the same performance.
> >
> > Bear in mind, though, that if you don't need entity groups for
> transaction
> > purposes, you should avoid using ancestor relationships. Given that, the
> > second approach is a better one - just not for query performance reasons.
> >
> > -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-appengine@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> > > google-appengine+unsubscr...@googlegroups.com e...@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
>
> --
> 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-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>


-- 
*— Vladimir Prudnikov, ToBeeDo*

-- 
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-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Are key filters more efficient than ancestor queries?

2010-07-19 Thread Blixt
Thanks Nick.

The reason I use entity groups is not for any kind of performance
reasons – I really need to make sure that the Parent entity is updated
in combination with a Child entity being added, and the values being
set are related to the order of entity insertions, so entity groups
feel like the right thing to do to ensure data atomicity.

My only thought is that I'd rather add redundancy (by adding a
ReferenceProperty that can be inferred from the key) than lose
performance. If the performance difference is negligible however, I'd
rather not add an unnecessary property.

/Blixt

On Jul 19, 1:21 pm, "Nick Johnson (Google)" 
wrote:
> Hi Blixt,
>
>
>
>
>
> On Mon, Jul 19, 2010 at 12:15 PM, Blixt  wrote:
> > Imagine the following models:
>
> > class Parent(db.Model):
> >    name = db.StringProperty()
> >    count = db.IntegerProperty()
>
> > class Child(db.Model):
> >    number = db.IntegerProperty()
> >    value = db.StringProperty()
>
> > Whenever a new Child is added, it is added with a Parent as its parent
> > entity in a transaction which also updates some values on the Parent.
>
> > My question is this: To get a list of children that belongs to a
> > Parent, is it more efficient to add a ReferenceProperty to the Child
> > model and filter by that, than it is to use the ancestor filter in
> > queries?
>
> > To clarify in code:
>
> > # Using ancestor
> > Child.all().ancestor(parent_key).fetch(10)
> > # Using filter on a new ReferenceProperty called 'my_parent'
> > Child.all().filter('my_parent', parent_key).fetch(10)
>
> These two should have roughly the same performance.
>
> Bear in mind, though, that if you don't need entity groups for transaction
> purposes, you should avoid using ancestor relationships. Given that, the
> second approach is a better one - just not for query performance reasons.
>
> -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-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com > e...@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

-- 
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-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.