drop table?

9 views
Skip to first unread message

Baron

unread,
Nov 2, 2009, 7:07:50 PM11/2/09
to Google App Engine
Hello,

I want to remove all records from a table. The table will have a lot
of records, so is it possible to somehow drop the table?
Or do I need to setup a taskqueue to progressively delete it?

thanks,
Richard

Wooble

unread,
Nov 2, 2009, 10:26:28 PM11/2/09
to Google App Engine
You need to delete all of the records individually. The datastore
doesn't really have any concept of a "table".

When writing the task, make sure you do keys_only queries; fetching
the whole entities will be unnecessarily slow (although deletes in
general are fairly slow as it is).

Baron

unread,
Nov 4, 2009, 11:15:56 PM11/4/09
to Google App Engine
thanks for the keys_only tip.
I removed ~30K records from the datastore, which used most of my daily
CPU quota. Is deleting meant to be this expensive?

Gabriel Robertson

unread,
Nov 4, 2009, 11:26:29 PM11/4/09
to google-a...@googlegroups.com
For note, the datastore is not like a databse, there is no such thing
as 'table'.

Think of it this way, your classes create a google protocol buffer,
and that binary stream is stored. For things like indexing with a
non-quality testing comparison operator (<,>,<=,etc...) it create a
new 'index' that points to the binary data.

Wooble

unread,
Nov 5, 2009, 8:51:38 AM11/5/09
to Google App Engine


On Nov 4, 11:15 pm, Baron <richar...@gmail.com> wrote:
> thanks for the keys_only tip.
> I removed ~30K records from the datastore, which used most of my daily
> CPU quota. Is deleting meant to be this expensive?

Yes; in the datastore deletes and puts are very expensive (since they
need to alter all of your indexes), and reads are very cheap. It's
definitely designed for applications where reads far outnumber writes.

Baron

unread,
Nov 6, 2009, 1:02:45 AM11/6/09
to Google App Engine
> > thanks for the keys_only tip.
> > I removed ~30K records from the datastore, which used most of my daily
> > CPU quota. Is deleting meant to be this expensive?
>
> Yes; in the datastore deletes and puts are very expensive (since they
> need to alter all of your indexes), and reads are very cheap.  It's
> definitely designed for applications where reads far outnumber writes.

Ah OK - thought I must be doing something wrong to burn my quota so
easily.
To reduce CPU usage is it possible to delay rebuilding the index until
all the data is uploaded?

Wooble

unread,
Nov 6, 2009, 10:10:53 AM11/6/09
to Google App Engine


On Nov 6, 1:02 am, Baron <richar...@gmail.com> wrote:
> Ah OK - thought I must be doing something wrong to burn my quota so
> easily.
> To reduce CPU usage is it possible to delay rebuilding the index until
> all the data is uploaded?

No, updating the indexes is an integral part of changing the entities;
if it weren't, you could get query results for entities that don't
exist and probably even more horrible consistency problems.

Baron

unread,
Nov 11, 2009, 8:43:40 AM11/11/09
to Google App Engine
can I use entities to speed up deleting? It seems when I give all my
model instances the same key_name the deleting is much faster because
"MyModel.all(keys_only=True)" returns only a single record now.
Am I missing something here?

Wooble

unread,
Nov 11, 2009, 12:40:19 PM11/11/09
to Google App Engine
Ummm... it sounds like you're only creating a single entity. This is
absolutely great if you want to delete it, and probably a big fail if
you want to use the datastore to, well, store data.

Baron

unread,
Nov 11, 2009, 10:23:17 PM11/11/09
to Google App Engine
yes I am creating a single entity with that key_name for all my
records (~100000). This also lets me use transactions on my records
now.

> a big fail if you want to use the datastore to, well, store data.
What side effects will this cause? - degraded response time?

Richard

ryan baldwin

unread,
Nov 11, 2009, 10:26:55 PM11/11/09
to google-a...@googlegroups.com
I can't imagine this being very performant. The serialization cost sounds like it would be extreme, no?

- ryan.

Nick Johnson (Google)

unread,
Nov 12, 2009, 5:39:32 AM11/12/09
to google-a...@googlegroups.com
Key names must be unique for a given kind and parent. If you do the following:

---
for i in range(100):
  MyEntity(key_name='foo', value=i).put()
---

you are overwriting the entity with key name 'foo' repeatedly with new values. Only the last one is stored.

-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

Baron

unread,
Nov 12, 2009, 7:54:15 PM11/12/09
to Google App Engine
thanks for the clarification Nick - reading the docs again makes that
clear.


On Nov 12, 9:39 pm, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:
> > google-appengi...@googlegroups.com<google-appengine%2Bunsu...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages