Search code examples
ibm-cloudcloudant

Delete "views" in Cloudant to make space


I am currently using the Lite version of Cloudant and I have reached the 1GB limit that is offered.
I tried to delete some data but as you can see in the picture below, the actual data in my database is not very heavy.
Most of the space seems to be taken up by views. Does anyone know what this represents and how we can get rid of them such that I can make some space in the database?

enter image description here


Solution

  • Views are secondary indexes generated by map and reduce functions in your design documents. They may have been created by a developer directly, or behind your back if you are using an application such as NodeRed. If you delete a design document, the associated index should be removed, but this may of course affect the functionality of whatever it is using your Cloudant database.

    Removing views WILL break any application expecting to find them there. Think carefully if this is really what you want to do. You should think about backing up your data first (https://github.com/cloudant/couchbackup).

    Views are stored in design documents. They are documents where the id starts with _design. You can list design docs using curl:

    % curl 'https://USER:[email protected]/DATABASE_all_docs?startkey="_design/"&endkey="_design0"'
    {"total_rows":8747,"offset":5352,"rows":[
        {"id":"_design/names","key":"_design/names","value":{"rev":"1-4b72567e275bec45a1e37562a707e363"}},
        {"id":"_design/queries","key":"_design/queries","value":{"rev":"7-7e128fa652e9a1942fb8a01f07ec497c"}},
        {"id":"_design/routeid","key":"_design/routeid","value":{"rev":"1-a04ab1fc814ac1eaa0b445aece032945"}},
        {"id":"_design/setters","key":"_design/setters","value":{"rev":"1-7bf0fc0255244248de4f89a20ff730f4"}}
    ]}
    

    You can then delete those with a curl -XDELETE ... -- or you can do it via the Cloudant dashboard.