Reads from multiple buckets?


#1

How does Couchbase handle reads from different buckets i.e. suppose I have a table in RDBMS which is quite big and does not fit in a bucket. So i make multiple buckets in couchbase. Now when I have to read the entire table how does couchbase know where the data is and how does it reads the data properly?

Also, I stored each documentID as table`s name+ Prikey of the table

eg: table - employee , pkey -id

couchbase doc id -> emp 1

So now if it is in multiple buckets in multiple nodes … How does couchbase read it i.e. collect the data and return it … like how you`ll write the view and how internally it works?


#2

Hello,

Why are you saying “I have a table in RDBMS which is quite big and does not fit in a bucket.” ?
Can you explain?

However to answer you question, if you need (I do not think in your case you need) to access 2 buckets, you need to create two clients (SDK) in your application and do get in both.

List uris = new LinkedList();
uris.add(URI.create(“http://server1:8091/pools”));
uris.add(URI.create(“http://server2:8091/pools”));
CouchbaseClient cbBucket1 = new CouchbaseClient(uris, “bucket1”, “”);
CouchbaseClient cbBucket2 = new CouchbaseClient(uris, “bucket1”, “”);

Object obj1 = cbBucket1.get(“key001”);
Object obj2 = cbBucket2.get(“key002”);

But remember that:

  • multiple buckets consume more resources on the server
  • multiple clients consume more resources on your application layer

Regards
Tug
@tgrall