tidb v4.0.2版本
开启事务,使用唯一索引前两列查询不到刚插入的数据
没有唯一键uk_tId_aa_bb时,查询也是没问题的
CREATE TABLE `test1` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`t_id` bigint(20) NOT NULL COMMENT 'tid',
`aa` varchar(20) NOT NULL COMMENT 'aa',
`bb` varchar(20) NOT NULL DEFAULT '' COMMENT 'bb',
`cc` varchar(128) NOT NULL DEFAULT '' COMMENT 'cc',
PRIMARY KEY (`id`),
KEY `idx_aa_bb_cc_id` (`aa`,`bb`,`cc`,`id`),
UNIQUE KEY `uk_tId_aa_bb` (`t_id`,`aa`,`bb`),
KEY `idx_tenantid` (`t_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=1020548 COMMENT='test';
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test1(t_id, aa, bb, cc) values(10086,'test1', 'test', '0-59/5 * * * *');
Query OK, 1 row affected (0.02 sec)
mysql> select * from test1 where t_id = 10086 and aa ='test1';
Empty set (0.00 sec)
mysql> select * from test1 where t_id = 10086;
+--------+-------+-------+------+----------------+
| id | t_id | aa | bb | cc |
+--------+-------+-------+------+----------------+
| 990548 | 10086 | test1 | test | 0-59/5 * * * * |
+--------+-------+-------+------+----------------+
1 row in set (0.01 sec)
mysql> select * from test1 where t_id = 10086 and aa ='test1';
Empty set (0.00 sec)
mysql> select * from test1 where t_id = 10086 and aa ='test1' and bb= 'test';
+--------+-------+-------+------+----------------+
| id | t_id | aa | bb | cc |
+--------+-------+-------+------+----------------+
| 990548 | 10086 | test1 | test | 0-59/5 * * * * |
+--------+-------+-------+------+----------------+
1 row in set (0.00 sec)