Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove built-in datastore indexes

The app engine defines a built-in index for every field by default. I didn't create them, and I don't want them.

My actual entities are only consuming 159MB, but the indexes consume an additional 680MB. I am only ever going to be doing key-queries on these entities, so I do not need any indexes at all. How can I remove these?

EDIT: Output of vacuum_indexes:

Found 0 unused indexes on the server.

Details:
No indexes were deleted.

vacuum_indexes completed successfully.
like image 867
Travis Webb Avatar asked Dec 21 '22 19:12

Travis Webb


2 Answers

You can not remove built-in indexes. They are built-in :)

What you can do is reduce the number of indexed used by your app's models. By default every property is indexed in AppEngine. I think you really mean about this.

To make a property unindexed, add a param to de property declaration like this:

class MyModel(db.Model):
    FirstName = db.StringProperty(Indexed=False)
    LastName = db.StringProperty(Indexed=False)
    ...

Thst's way, appengine will stop to use/create an index for that specific property. Next time you run you SDK console, indexes.yaml file will be updated automatically.

The last thing you need to do is execute appcfg.py vacuum_indexes myapp/. Read more about the last command on the Appengine SDK docummentation.

like image 56
Christopher Ramírez Avatar answered Dec 24 '22 01:12

Christopher Ramírez


With the low-level Java API you need to use the setUnindexedProperty method for all properties you don't want to have an built-in index on. There's no way of simply changing some definiton file and vacuuming to get rid of index entries that are already there. The only way to remove those built-in index entries (or to create new ones) is to re-write all your entities. Be aware though, that deletion of one index entry on one single entity will count as 2 full writes against your quota as these are actually 2 index entries - one in ascending the other in descending order.

like image 20
as5wolf Avatar answered Dec 24 '22 03:12

as5wolf