我们有一个简单的表,既没有外键也没有主键(对于此测试)。除了类型为十进制(5,4)的p之外,所有列均为int或tinyint。
以下是我们正在运行的查询的一部分。需要40秒才能完成。
我们现在正在Phpmyadmin中运行它。但是在测试我们的Laravel应用程序时出现了问题,这花费了太多时间才能完成此简单任务。
我们的表配置为: InnoDB-行格式:DYNAMIC-Latin1_Swedish_ci
MySQL版本:5.7.31-0ubuntu0.18.04.1 在Ubuntu服务器上运行。
DELETE FROM test WHERE species_id = 290;
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 16);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 15);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 14);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 11);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 17);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 13);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 99999);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 5);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 29);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 21);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 38);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 7);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 30);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 6);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 37);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 40);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 36);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100003);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100008);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100015);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 8);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 2);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 39);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 1);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 42);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 4);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100016);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 28);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 12);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 26);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 24);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 23);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100000);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 25);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 9);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 22);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 18);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 10);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100005);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 20);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100002);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 27);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 19);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 3);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 35);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100004);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100007);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100006);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 34);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 33);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100010);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100011);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100009);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100012);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100014);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 100013);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 32);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 1, 0, 31);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 16);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 15);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 14);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 11);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 17);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 13);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 99999);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 5);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 29);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 21);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 38);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 7);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 30);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 6);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 37);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 40);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 36);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 100003);
INSERT INTO test (species_id, month, p, beta_set_id) VALUES (290, 2, 0, 100008);
...