griddb icon indicating copy to clipboard operation
griddb copied to clipboard

I have created an index, but explain sql does not use the index

Open tom055 opened this issue 1 year ago • 1 comments

griddb 5.1.0

gs[public]> explain analyze select * from properties_test where deviceId='101' and property='0' limit 0,10;
The query had been executed. (60,662 ms)
gs[public]> getplantxt
Id Type     Input Rows Lead time Actual time Node               And more..                         
---------------------------------------------------------------------------------------------------
 0 SCAN     -     -        60597       48739 192.168.1.62:10001 table: {properties_test} LIMIT: 10
 1   RESULT 0     10           0           0 192.168.1.62:20001                                   
gs[public]> showcontainer properties_test
Database    : public
Name        : properties_test
Type        : COLLECTION
Partition ID: 13
DataAffinity: -

Columns:
No  Name                  Type            CSTR  RowKey
------------------------------------------------------------------------------
 0  Type                  STRING                
 1  DeviceId              STRING                
 2  Property              STRING                
 3  Id                    STRING                
 4  NumberValue           DOUBLE                
 5  Value                 STRING                
 6  CreateTime            TIMESTAMP             
 7  Timestamp             TIMESTAMP             

Indexes:
Name        : 
Type        : TREE
Columns:
No  Name                  
--------------------------
 0  Property

Name        : 
Type        : TREE
Columns:
No  Name                  
--------------------------
 0  DeviceId

Name        : 
Type        : TREE
Columns:
No  Name                  
--------------------------
 0  Timestamp

Name        : 
Type        : TREE
Columns:
No  Name                  
--------------------------
 0  DeviceId
 1  Property

tom055 avatar Mar 20 '23 06:03 tom055

Sorry for late reply.

Thank you for your report.

The output of "getplantxt" doesn't include the detailed information.

gs[public]> getplantxt Id Type Input Rows Lead time Actual time Node And more..

0 SCAN - - 60597 48739 192.168.1.62:10001 table: {properties_test} LIMIT: 10 1 RESULT 0 10 0 0 192.168.1.62:20001

Could you use "gettaskplan" for Plan Id = 0 (Type = SCAN) ? It will include the following information.

gs[public]> gettaskplan 0

        ...
        "index" : [ {
          "actualTime" : 0,
          "columnList" : [ "DeviceId", "Property" ],
          "conditionList" : [ {
            "column" : "DeviceId",
            "condition" : "EQ"
          }, {
            "column" : "Property",
            "condition" : "EQ"
          } ],
          ...
          "type" : "SCAN_CONTAINER_INDEX"
          ...

knonomura avatar Aug 22 '23 10:08 knonomura