What is preferred way of getting Couchbase bucket data in mobile application using N1QL or SDK

I am using Cocuhbase server along with Sync_gateway.
Mobile device data is synced with couchbase bucket.
Now I want to get some data from Couchbase Bucket to mobile device.

I can get the data using Couchlite SDK or using N1QL query.
What is preferred way for this from performance point of view.

Getting data using SDK will add lesser pressure on server than using N1QL ?

Which version of Sync Gateway/ Couchbase Server are you using? If you are on SGW versions (>=1.5) that support it, you can leverage shared bucket access feature. With shared bucket access, you can write to the couchbase server bucket from your web app and that will get synced over. Versions of SGW < 1.5 will not work this way. You can check out this blog for more info on the same.

What language are you developing with? We support SDKs for most commonly used languages and should be leveraged for this purpose. That’s one of the objectives of the SDK - to make it simpler for app developers to interface with our server.

There shouldn’t be any difference in load on server using the SDK over raw N1QL.

This is definitely true, but there is a difference in the performance profile of the different kinds of operations you perform from the SDK. N1QL queries are much more expressive, but require a lot more ‘work’ on the part of the cluster to service the request, where what the documentation refers to as “core operations” use a simple, fast approach to get to the exact node responsible for the data.

While there’s no hard and fast rule, if you’re looking mostly for full document access by the key/id and latency or resource usage are important to you, use the core operations from the SDK. If you’re looking to get a set of documents by range query on either the key/id or on a secondary index attribute or you’re looking to project/transform data, N1QL will be best. Of course, there’s another option which is if you’re looking to match things in a fuzzier sense, the FTS search will work for you. All of these are available in the underlying SDKs.

1 Like

Thanks @ingenthr and priya.
This information is very helpful for me.