Hi yejun,

I didn't see any immediate problems with the first approach which you
listed, I agree it will be more efficient than the second approach.
Depending on the shape of your data you might need to adjust the
number of items which you fetch and delete in a single request (100
could be too many to try to delete in one request in some cases).

The second approach listed will probably be slower, since a delete
with multiple entities may be able to perform deletes in parallel. It
also seems like the loop will run until one of the transactions fails
which might be too long for the HTTP request to return a result within
the alloted time.

Thank you,

Jeff

On Oct 22, 1:56 pm, yejun <[EMAIL PROTECTED]> wrote:
> The model is very simple here.
> class table(db.Model)
>     atime=db.DateTimeProperty(auto_now=True)
>     data=db.BlobProperty()
>
> I want to have function simply delete data older than a certain time.
>
> Is it safe to use just
>
> db.delete(table.all().filter('atime <', expire_time).fetch(100))
>
> or do I have to do it like this
>
> def txn():
>     old = table.all().filter('atime <', expire_time).get()
>     if old is not None:
>         old.delete()
>         return True
>     return False
> while run_in_transaction(txn): pass
>
> My concern is that the first method may delete an entry is being
> updated. The second method seems very inefficient.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to