我有简单的SELECT QUERY,需要3秒多才能得到结果。实际结果计数为15211
查询:
select meta().id assetId, modelAndPart.partNumberID,assetLocation.id locationId from ic_v10_mammoet where type = 'asset' and modelAndPart IS NOT null and tenantId='439'
说明:
{
"requestID": "cda5ed1b-efaf-4c5b-bb67-81f0a3542324",
"clientContextID": "13583a95-04cc-4722-90dd-9642068f9ea0",
"signature": "json",
"results": [
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan",
"index": "type_idx",
"index_id": "f1d17cd15ab5feb6",
"keyspace": "ic_v10_mammoet",
"namespace": "default",
"spans": [
{
"Range": {
"High": [
"\"asset\""
],
"Inclusion": 3,
"Low": [
"\"asset\""
]
}
}
],
"using": "gsi"
},
{
"#operator": "Fetch",
"keyspace": "ic_v10_mammoet",
"namespace": "default"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((((`ic_v10_mammoet`.`type`) = \"asset\") and ((`ic_v10_mammoet`.`modelAndPart`) is not null)) and ((`ic_v10_mammoet`.`tenantId`) = \"439\"))"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"as": "assetId",
"expr": "(meta(`ic_v10_mammoet`).`id`)"
},
{
"expr": "((`ic_v10_mammoet`.`modelAndPart`).`partNumberID`)"
},
{
"as": "locationId",
"expr": "((`ic_v10_mammoet`.`assetLocation`).`id`)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
},
"text": "select meta().id assetId, modelAndPart.partNumberID,assetLocation.id locationId from ic_v10_mammoet where type = 'asset' and modelAndPart IS NOT null and tenantId='439'"
}
],
"status": "success",
"metrics": {
"elapsedTime": "15.0015ms",
"executionTime": "15.0015ms",
"resultCount": 1,
"resultSize": 3009
}
}
答案 0 :(得分:1)
是的,你忘了问一个问题。您可以使用此索引。
CREATE INDEX idx_assets ON somedata
( tenantId, modelAndPart.partNumberID, assetLocation.id )
WHERE type = 'asset';