Cloudant Partitioned Databases — Introduction

Glynn Bird
Mar 5 · 5 min read

Creating a partitioned database

$ curl -X PUT "$URL/mydb" {"ok": true}
$ curl -X PUT "$URL/mypartitioneddb?partitioned=true" {"ok": true}

The two-part _id field

The two-part document _id : partition_key:document_key

How Cloudant stores data in a partitioned database

Partitioned queries hit only the shard that hosts the partition, where as a global query hits all partitions.

What makes a good partition key?

Partition database CRUD

PUT /<database>/<partitionkey>:<dockey> POST /<database> (supplying a JSON document with a two-part _id) GET /<database><partitionkey>:<dockey> DELETE /<database>/<partitionkey>:<dockey>?rev=<revision> POST /<database>/_bulk_get POST /<database>/_bulk_docs

Querying a single partition

Cloudant Query _find

POST /<database>/_partition/<partitionkey>/_find

Cloudant Query MapReduce

GET /<database>/_partition/<partitionkey>/_design/<name>/_view/<view_name>

Cloudant Search

GET /<database>/_partition/<partitionkey>/_design/<name>/_search/<index_name>

All documents

GET /<database>/_partition/<partitionkey>/_all_docs

Pricing

Summary

Further reading

Glynn Bird

Written by

Developer @ IBM. https://glynnbird.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade