Details
Description
Build: 7.0.0-4332
Create kv: `default`.scope1.collection1
Load 1000 docs into collection1, all docs look like:
{
|
"mutated": 0, |
"join_date": "1951-09-25T17:47:20", |
"languages_known": [ |
"German", |
"Arabic", |
"Romanian" |
],
|
"manages": { |
"reports": [ |
"Maura Campbell", |
"Alvita Baker III", |
"Trista Smith", |
"Mercedes Hall", |
"Kerry-Ann Ward", |
"Keelia Robinson Sr.", |
"Mia Richardson IX" |
],
|
"team_size": 7 |
},
|
"name": "Adara Baker III", |
"dept": "Pre-sales", |
"salary": 101367, |
"type": "emp", |
"is_manager": true, |
"email": "Adara@mcdiabetes.com", |
"emp_id": "10000001" |
}
|
Create FTS index:
{
|
"name": "default_index_1", |
"type": "fulltext-index", |
"params": { |
"doc_config": { |
"docid_prefix_delim": "", |
"docid_regexp": "", |
"mode": "scope.collection.type_field", |
"type_field": "type" |
},
|
"mapping": { |
"default_analyzer": "keyword", |
"default_datetime_parser": "dateTimeOptional", |
"default_field": "_all", |
"default_mapping": { |
"dynamic": false, |
"enabled": false |
},
|
"default_type": "_default", |
"docvalues_dynamic": true, |
"index_dynamic": true, |
"store_dynamic": false, |
"type_field": "_type", |
"types": { |
"scope1.collection1": { |
"default_analyzer": "keyword", |
"dynamic": true, |
"enabled": true |
}
|
}
|
},
|
"store": { |
"indexType": "scorch", |
"mossStoreOptions": {}, |
"segmentVersion": 15 |
}
|
},
|
"sourceType": "gocbcore", |
"sourceName": "default", |
"sourceUUID": "ab448c157c43a29fb90e64ba81da7c16", |
"sourceParams": {}, |
"planParams": { |
"maxPartitionsPerPIndex": 171, |
"numReplicas": 0, |
"indexPartitions": 6 |
},
|
"uuid": "1d4a0c882b4ac411" |
}
|
Run the following query
explain select count(*) from `default`.scope1.collection1 USE INDEX(USING FTS) where type in ['emp', 'emp1'] |
Result is:
[
|
{
|
"plan": { |
"#operator": "Sequence", |
"~children": [ |
{
|
"#operator": "IndexFtsSearch", |
"bucket": "default", |
"covers": [ |
"cover (((`collection1`.`type`) in [\"emp\", \"emp1\"]))", |
"cover ((meta(`collection1`).`id`))" |
],
|
"index": "default_index_1", |
"index_id": "1d4a0c882b4ac411", |
"keyspace": "collection1", |
"namespace": "default", |
"scope": "scope1", |
"search_info": { |
"field": "\"\"", |
"options": "{\"index\": \"default_index_1\"}", |
"outname": "out", |
"query": "{\"query\": {\"disjuncts\": [{\"field\": \"type\", \"term\": \"emp\"}, {\"field\": \"type\", \"term\": \"emp1\"}]}, \"score\": \"none\"}" |
},
|
"using": "fts" |
},
|
{
|
"#operator": "Parallel", |
"~child": { |
"#operator": "Sequence", |
"~children": [ |
{
|
"#operator": "Filter", |
"condition": "cover (((`collection1`.`type`) in [\"emp\", \"emp1\"]))" |
},
|
{
|
"#operator": "InitialGroup", |
"aggregates": [ |
"count(*)" |
],
|
"group_keys": [] |
}
|
]
|
}
|
},
|
{
|
"#operator": "IntermediateGroup", |
"aggregates": [ |
"count(*)" |
],
|
"group_keys": [] |
},
|
{
|
"#operator": "FinalGroup", |
"aggregates": [ |
"count(*)" |
],
|
"group_keys": [] |
},
|
{
|
"#operator": "Parallel", |
"~child": { |
"#operator": "Sequence", |
"~children": [ |
{
|
"#operator": "InitialProject", |
"result_terms": [ |
{
|
"expr": "count(*)" |
}
|
]
|
}
|
]
|
}
|
}
|
]
|
},
|
"text": "select count(*) from `default`.scope1.collection1 USE INDEX(USING FTS) where type in ['emp', 'emp1']" |
}
|
]
|
In this plan I cannot detect anything about aggregate pushdown, like it can be found in case of GSI index ("index_group_aggs" section):
GSI query:
explain select count(*) from `default`.scope1.collection1 where type in ['emp', 'emp1'] |
GSI index:
create index ix1 on `default`.scope1.collection1(`type`) |
GSI plan:
[
|
{
|
"plan": { |
"#operator": "Sequence", |
"~children": [ |
{
|
"#operator": "IndexScan3", |
"bucket": "default", |
"covers": [ |
"cover ((`collection1`.`type`))", |
"cover ((meta(`collection1`).`id`))", |
"cover (count(*))" |
],
|
"index": "ix1", |
"index_group_aggs": { |
"aggregates": [ |
{
|
"aggregate": "COUNT", |
"expr": "1", |
"id": 2, |
"keypos": -1 |
}
|
]
|
},
|
"index_id": "60ea680f00422cfd", |
"index_projection": { |
"entry_keys": [ |
2 |
]
|
},
|
"keyspace": "collection1", |
"namespace": "default", |
"scope": "scope1", |
"spans": [ |
{
|
"exact": true, |
"range": [ |
{
|
"high": "\"emp\"", |
"inclusion": 3, |
"low": "\"emp\"" |
}
|
]
|
},
|
{
|
"exact": true, |
"range": [ |
{
|
"high": "\"emp1\"", |
"inclusion": 3, |
"low": "\"emp1\"" |
}
|
]
|
}
|
],
|
"using": "gsi" |
},
|
{
|
"#operator": "Parallel", |
"~child": { |
"#operator": "Sequence", |
"~children": [ |
{
|
"#operator": "InitialProject", |
"result_terms": [ |
{
|
"expr": "cover (count(*))" |
}
|
]
|
}
|
]
|
}
|
}
|
]
|
},
|
"text": "select count(*) from `default`.scope1.collection1 where type in ['emp', 'emp1']" |
}
|
]
|