We tried to perform a count(*) on an indexed field today and it seems to be using a full #alldocs scan instead.
create index objectid on entities_service(entity.objectid)
explain select count(entities_service.entity.objectid) from entities_service
{
"resultset": [
{
"input": {
"aggregates": [
{
"distinct": false,
"name": "COUNT",
"operands": [
{
"expr": {
"left": {
"left": {
"path": "entities_service",
"type": "property"
},
"right": {
"path": "entity",
"type": "property"
},
"type": "dot_member"
},
"right": {
"path": "objectid",
"type": "property"
},
"type": "dot_member"
},
"star": false
}
],
"type": "function"
}
],
"group": [],
"input": {
"as": "entities_service",
"bucket": "entities_service",
"input": {
"bucket": "entities_service",
"index": "#alldocs",
"pool": "default",
"ranges": null,
"type": "scan"
},
"pool": "default",
"projection": null,
"type": "fetch"
},
"type": "grouper"
},
"result": [
{
"as": "$1",
"expr": {
"distinct": false,
"name": "COUNT",
"operands": [
{
"expr": {
"left": {
"left": {
"path": "entities_service",
"type": "property"
},
"right": {
"path": "entity",
"type": "property"
},
"type": "dot_member"
},
"right": {
"path": "objectid",
"type": "property"
},
"type": "dot_member"
},
"star": false
}
],
"type": "function"
},
"star": false
}
],
"type": "projector"
}
]
}