2017-03-03 101 views
0

我有简单的SELECT QUERY,它需要超过3秒才能得到结果。实际结果数为15211Couchbase select查询性能

查询:

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';