Currently We have a XML database as an existing database in our application. we want to migrate to NOSQL database, So
we are checking the performance of Couchbase and MongoDB. I have read that Couchbase is faster than MongoDB in some of the Technical forms of couchbase but When I compare the performance of MongoDB with Couchbase, Mongodb performance is better than Couchbase.
Note: I have only Checked the performance Read operation in Single Database Server(Single Node Environment).
Environment:
Installed Couchbase: couchbase-server-community_4.0.0-windows_amd64
Java_SDK(Client): Couchbase-Java-Client-2.2.8 (Contains: rxjava-1.0.17.jar, couchbase-java-client-2.2.8.jar, rxjava-1.0.17.jar)
OS Version: Windows7 - 64 bit
RAM: 8GB
HD: 500GB
Please find the following code for insertion and Retrieval:
Inserting:
String finalData = “{“device”:{“y”:{“devicesmsPropertyList”:{“dskFlag”:“false”,“serialId”:1000,“inputTray”:{“LIST”:{“e”:[{“inTray”:{“id”:“1” etc…}}}}”;
JsonObject infoObj = JsonObject.create().put(“deviceinfo”, JsonObject.fromJson(finalData));
bucket.upsert(JsonDocument.create(“device” + i, infoObj));
Fetching:
// Create a N1QL Primary Index (but ignore if it exists)
bucket.bucketManager().createN1qlPrimaryIndex(true, false);
List list = new ArrayList<>();
N1qlQueryResult result = bucket.query(N1qlQuery.simple(“SELECT deviceinfo.device.deviceId, ipAddress,deviceinfo.device.noResponse,deviceinfo.device.deviceImageUrl,deviceinfo.device.createTimestamp,deviceinfo.device.deviceImageWidth,deviceinfo.device.deviceImageHeight,deviceinfo.device.communicationResult, deviceinfo.device.y, deviceinfo.device.latestInfo.smsProperty.timestamp FROM default
LIMIT 30;”));
for (N1qlQueryRow row : result) {
list.add("{\"device\":" + row + "}");
}
// Sending list to the browser to display.
I am using the same configuration and datamodel for both Mongodb and Couchbase.
Please let me know If I am missing anything while inserting or Fetching into/from the Bucket of Couchbase.