Hi all,
I am working on a C# program that pulls data from our Couchbase server. I’m running into a very confusing issue where I have two queries that I need to run.
One is both very fast in code and very fast in the Query window on the Couchbase console.
The second one is extremely slow in code, but is just as fast in the Query window on the Couchbase console.
Query A
select meta(mybucket).id from mybucket
where _deleted is missing
and organization=“myorganization”
and type=“Apple”
Query B:
select meta(mybucket).id from mybucket
where _deleted is missing
and organization=“myorganization”
and type=“compilation”
and formTemplate=“AppleCompilation”
In this particular case, each piece of information has two associated records. One is the original data (type Apple), and the other is a compilation of data from the first (ie. AppleCompilation). So they are a 1 to 1.
As such, each query pulls the exact same amount of data.
Also both have an accompanying index in Couchbase.
When I run Query A in the Couchbase Query window, I get 250 results and it takes 30ms.
In C#, if I run the command:
var results = await ClusterHelper.GetBucket(“mybucket”).QueryAsync(query);
It takes 30ms.
Essentially the exact same amount of time.
If I run Query B. It also takes 30ms in the Query window.
However, in the C# code, it takes 900ms.
It takes 30x longer.
I simply have no idea why. Some of these queries have 300,000 results, so when it takes 20 - 30 seconds in the Query window, it’s taking 10 to 15 minutes in C#!
I cannot find any reasoning for this, and after two days of chugging through it, I haven’t gotten any further.
Can someone help shed some light on this subject? Things I can examine?
Thanks