Total Result Count

As above query must require sort and will not use index sort.

See if you can use sortCount from metrics of the query results. As query required sort it must produce all possible values and those will be input to sort. So sortCount will reflect that value (If not ORDER BY or query uses index order, sortCount will not present, this particular query it will present)

  "metrics": {
        "elapsedTime": "3.193804ms",
        "executionTime": "3.130265ms",
        "resultCount": 12,
        "resultSize": 2485,
        "sortCount": 12
    }

If that doesn’t work checkout the following post

Also the following might be useful because join, group, pagination expensive

OFFSET and Keyset Pagination in N1QL Query | Couchbase