如果 table 中的行数很大(200 万),NDB cluster7.5(MySQL 5.7) 会花费更多时间来获取数据

NDB cluster7.5(MySQL 5.7) is taking more time in fetching data, if number of rows in table is large(2 million)

我正在尝试为我的一个实时应用程序(具有大量读写并发)设置 NDB 集群(MYsql 5.7)。

我的设置 -

3 个数据节点 1个管理节点 1 MySQL 个节点

所有节点都是 amazon EC2 r3.4xlarge 类型。 OS - centos 7

我创建了一个 table 并按主键分区以确保相同的主键数据进入单个节点。

Table Schema -
CREATE TABLE ContactsAgentContacts(
       uniqueid integer not null,
       did varchar(32) not null,
       nId varchar(50),
       companyname varchar(50),
primary key (uniqueid,did)
) 

引擎=NDBCLUSTER 按键分区(did);

现在我用 200 万条记录填充了我的 table,这样每条记录都包含 1K 条记录。

已触发查询 - SELECT DISTINCT ContactsAgentContacts.companyname AS 'fullname' from ContactsAgentContacts where did='xyz';

性能得到 -

单并发 - 正在获取一个 did 的 1k 条记录

**with 1 read concurrency - 800 ms
with 25 read concurrency - 1.5 sec
with 50 read concurrency - 3 sec**

因为我正在尝试开发一个实时系统,任何超过 300 毫秒的值对我来说都太多了,而且随着 table 中行数的增加,这个时间也在增加。 请让我知道如何优化我的解决方案。

My configiration .
config.ini

[tcp default]
SendBufferMemory=2M
ReceiveBufferMemory=2M

[ndb_mgmd default]
# Directory for MGM node log files
DataDir=/var/lib/mysql-cluster

[ndb_mgmd]
#Management Node db1
HostName=10.2.25.129
NodeId=1

[ndbd default]
NoOfReplicas=1
DataMemory=2000M
IndexMemory=300M
LockPagesInMainMemory=1
#Directory for Data Node
DataDir=/var/lib/mysql-cluster
NoOfFragmentLogFiles=300
MaxNoOfConcurrentOperations=100000
SchedulerSpinTimer=400
SchedulerExecutionTimer=100
RealTimeScheduler=1
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=200
RedoBuffer=32M

[ndbd]
#Data Node db2
HostName=10.2.18.81
NodeId=2
#LockExecuteThreadToCPU=1
LockMaintThreadsToCPU=0

[ndbd]
#Data Node db3
HostName=10.2.20.15
NodeId=3
#LockExecuteThreadToCPU=1
LockMaintThreadsToCPU=0

[ndbd]
#Data Node db4
HostName=10.2.24.28
NodeId=4
#LockExecuteThreadToCPU=1
LockMaintThreadsToCPU=0

[mysqld]
#SQL Node db5
HostName=10.2.29.42
NodeId=5

切换到主键(did,uniqueid)意味着 主键上的有序索引将用于扫描 对其中一个分区进行全面 table 扫描。

这应该会大大改善事情。