Error GsiScanClient: response failed Index scan timed out

Couchbase community edition 5.0.1

We are seeing this error every day when executing a given query. There is a single bucket with ~25Million records. An index is created on a field.

Sample Doc:

a:“str1”
b:“str2”
c:{str3:num}
d:“str3”

Index: CREATE INDEX ON bucket((c.num)) where num has 6 different values(1 to 6).

The field c.num is present in almost all the 25M records.

Query pattern: select meta().id, b.* from bucket b where c.num=1;

Explain plan:

{
“plan”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “IndexCountScan2”,
“covers”: [
“cover (((bucket.c).num))”,
“cover ((meta(bucket).id))”
],
“index”: “c_num”,
“index_id”: “e349bd17481dab83”,
“keyspace”: “bucket”,
“namespace”: “default”,
“spans”: [
{
“exact”: true,
“range”: [
{
“high”: “5”,
“inclusion”: 3,
“low”: “5”
}
]
}
],
“using”: “gsi”
},
{
#operator”: “IndexCountProject”,
“result_terms”: [
{
“expr”: “count()"
}
]
}
]
},
“text”: "SELECT count(
) from bucket where c.num=5;”
}

Thank you for your help.

Use this technique and select document keys and then use SDKs to fetch document vs using N1QL fetch the document which needs go through 2 hops of 25M documents.