Multiple Buckets
Is it a good idea to create multiple buckets, one for each document type (roughly equal to one bucket per table in the schema world). If not, what is the right approach for organizing data? Currently, we have all our data in the default bucket, it is inconvenient.
Hi Bhuvana,
Bucket are similar to databases rather than tables. Depending on your hardware we would recommend some where from 2-4 buckets to 7-10 buckets.
If you take a look at the architecture, http://www.couchbase.com/docs/couchbase-manual-1.8/couchbase-architectur... you will see that for each bucket, an instance of the bucket engine (component) is created. Each bucket takes up a part of memory and it is managed independently. Using multiple buckets could lead to heavy CPU usage. So creating multiple buckets does have an impact on the system.
Given the power of Javascript map functions, multiple objects can be stored in the same bucket, and secondary indexes can be created on attributes for each document type.
Example:
function(doc, meta) {
if (doc.jsonType == "player") {
emit(doc.experience, doc);
}
}
More examples and information on views can be found here:
- http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi...
- http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-sampl...
Bhuvana:
This is certainly a feasible approach.
For example, refer to
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi...
Refer to the Using Document Types which talks about storing different data types in different buckets.
Also, Buckets are resource units (such as RAM quota, replication, etc.) within Couchbase.
Rags