If you don't need the entity, count(1) would be faster than fetch(1) or
get().
-- Dan

On Mon, Jan 12, 2009 at 12:54 PM, SM <sanja...@gmail.com> wrote:

>
>
> I have a simple model like this:
>
> class MyModel(db.Model):
>  prop = db.StringProperty()
>  active = db.BooleanProperty(default=False)
>
> Given an input string, s, I'd like to know if it is in the datastore.
> Would this be the best way to check?
>
> if MyModel.gql("WHERE prop = :1 AND active = True", s).fetch(1):
>  print "Found"
> else:
>  print "Not found"
>
> Is there a faster/better way? Do I need to do anything with indexes to
> make this query better?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to