I have table with 10M rows.
CREATE TABLE Plan_NDB (
PlanID int NOT NULL,
RepayAmount numeric(12, 2) not null default 0.0,
RepayRemain numeric(12, 2) not null default 0.0,
ClearType varchar(20) not null default ' ',
RepayResult varchar(20) not null default ' ',
RepayStatus varchar(20) not null default ' ',
StartDate numeric(8, 0) not null default 0,
MatchDate numeric(8, 0) not null default 0,
RepayDate numeric(8, 0) not null default 0,
PRIMARY KEY (PlanID),
Key (ClearType,RepayAmount)
) ENGINE NDBCLUSTER ;
I have 4 data nodes in this cluster , when I execute below query , it's really slow then the same table but in Innodb.
select ClearType,sum(RepayAmount) from Plan_NDB group by ClearType;
In Cluster it's 27sec. but in Innodb , only 3 secs.
I did the explain , it shows full index scan. the same plan with innodb.
I'm not 100% sure is the index covering working for cluster or not, can someone help to explain ?
some information for your reference.
analyze table Plan_NDB;
show index from Plan_NDB from QCDATA;
----------------------------------------------------------------------------------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|Plan_NDB | 0 | PRIMARY | 1 | RepayPlanID | A | 10000000 | NULL | NULL | | BTREE | | |
|Plan_NDB | 1 | ClearType | 1 | ClearType | A | 3 | NULL | NULL | | BTREE | | |
|Plan_NDB | 1 | ClearType | 2 | RepayAmount | A | 2498 | NULL | NULL | | BTREE | | |
+----------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
----------------------------------------------------------------------------------
explain extended select ClearType,sum(RepayAmount) from Plan_NDB group by ClearType
----------------------------------------------------------------------------------
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
| 1 | SIMPLE | Plan_NDB | index | NULL | ClearType | 48 | NULL | 10000000 | 100.00 | NULL |
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
any tuning advice is appreciated!
CREATE TABLE Plan_NDB (
PlanID int NOT NULL,
RepayAmount numeric(12, 2) not null default 0.0,
RepayRemain numeric(12, 2) not null default 0.0,
ClearType varchar(20) not null default ' ',
RepayResult varchar(20) not null default ' ',
RepayStatus varchar(20) not null default ' ',
StartDate numeric(8, 0) not null default 0,
MatchDate numeric(8, 0) not null default 0,
RepayDate numeric(8, 0) not null default 0,
PRIMARY KEY (PlanID),
Key (ClearType,RepayAmount)
) ENGINE NDBCLUSTER ;
I have 4 data nodes in this cluster , when I execute below query , it's really slow then the same table but in Innodb.
select ClearType,sum(RepayAmount) from Plan_NDB group by ClearType;
In Cluster it's 27sec. but in Innodb , only 3 secs.
I did the explain , it shows full index scan. the same plan with innodb.
I'm not 100% sure is the index covering working for cluster or not, can someone help to explain ?
some information for your reference.
analyze table Plan_NDB;
show index from Plan_NDB from QCDATA;
----------------------------------------------------------------------------------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|Plan_NDB | 0 | PRIMARY | 1 | RepayPlanID | A | 10000000 | NULL | NULL | | BTREE | | |
|Plan_NDB | 1 | ClearType | 1 | ClearType | A | 3 | NULL | NULL | | BTREE | | |
|Plan_NDB | 1 | ClearType | 2 | RepayAmount | A | 2498 | NULL | NULL | | BTREE | | |
+----------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
----------------------------------------------------------------------------------
explain extended select ClearType,sum(RepayAmount) from Plan_NDB group by ClearType
----------------------------------------------------------------------------------
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
| 1 | SIMPLE | Plan_NDB | index | NULL | ClearType | 48 | NULL | 10000000 | 100.00 | NULL |
+----+-------------+----------------------+-------+---------------+-----------+---------+------+----------+----------+-------+
any tuning advice is appreciated!