我有一个脚本,它几乎每一秒都在做大量的选择和插入,而且总查询数从一秒到另一秒不等。下面是运行查询的结果,最后是命令不同步下面的错误;你现在不能运行这个命令,或者有时它会让我失去连接。
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.116','00:14:5E:95:B9:18','53',995,7)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.172','90:F6:52:20:15:E8','2049',5599,16)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.222','00:0C:29:EE:DE:BC','0',60,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.235','00:1E:90:3B:92:AA','17500',408,2)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.24','00:30:1E:F2:5F:B8','0',60,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.250','00:1E:68:5C:CF:93','32767',175,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.43','20:CF:30:5E:0B:41','137',359,3)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.52','00:1E:0B:85:B0:B1','22',10963,40)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.57','00:24:E8:79:BD:3B','5060',561,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.65','00:1A:64:21:D6:B4','0',60,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.160.9','00:09:0F:EF:DA:31','0',60,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.115','00:00:1C:DC:22:45','17500',408,2)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.137','D8:30:62:63:65:40','0',60,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.16','00:1E:90:3B:8F:6C','137',92,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.212','48:5D:60:00:DE:C0','137',359,3)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.233','00:25:64:CB:92:5C','17500',604,4)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.234','00:0C:29:34:8E:FF','137',92,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','10.207.161.3','00:D0:4C:D0:13:B8','32767',1524,19)
Time is 2012-07-16 23:51:46Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','169.254.122.188','00:19:21:3B:F4:17','32767',175,1)
Query 2 after executing INSERT INTO export1 (iBTID ,timeStampID ,ipSource ,macSource,portSource,totalBits, packetCount) VALUES (NULL,'2012-07-16 23:51:45','203.91.121.76','00:60:E0:44:E4:B2','32767',1062,9)
Error in second query of insert Commands out of sync; you can't run this command now
如果
iBTID
是表中的 auto_increment 列export1
,您可能需要更改 INSERT INTO 命令以排除该列,如下所示:每次你 INSERT 并交给 mysqld 一个你将 auto_increment 列设置为 NULL 的行时,mysqld 会尝试通过查找下一个 auto_increment 值并在内部处理它来协调 INSERT 的主键。这可能对 mysqld 有点负担,因为将 PRIMARY KEY(全部定义为
NOT NULL
)一个 NULL 值强制执行此协调工作。就 ANSI SQL 而言,这真的很不自然。