Search code examples
javagoogle-app-enginegoogle-cloud-datastore

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.

Solution

  • 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.