couchdbcloudant

Does couch DB have a partition key and sort key?


Does couch DB have a partition key and sort key? If yes, What is the sorting logic and theory?


Solution

  • Recent versions of CouchDB support partitioned databases, letting you specify an explicit partition as a document id of the form mypartition:documentid. For certain use cases, this can be a very efficient way of organising your data, with partitioned view queries not having to visit every shard. Note that there are some quirks to be aware of in terms of partition sizes etc. A database can be created as partitioned, but an existing (non-partitioned) database can't be made partitioned at a later stage. Cloudant wrote a handy blog post introducing partitioned databases.

    There is no separate sort key; ordering is determined by the document id (or for views, the view key). The ordering is lexicographical on the key.