不批量插入数据时是否需要重建索引?
让我重新表述一下这个问题:
这对于 /*! 至关重要吗?使用单独的 INSERT 语句插入数据时,下面的 SQL 文件中的 */
行是否存在?
这是现在文件的内容:
LOCK TABLES `adv_links` WRITE;
/*!40000 ALTER TABLE `adv_links` DISABLE KEYS */;
INSERT INTO `adv_links` VALUES (13,'photoreal','http://w.otoreal.tk','',14,'something','something, something',64,0,1,1,'',0,'',1277754393,1277754393,0,0,0,'85.72.100.18',0,0,0,'');
INSERT INTO `adv_links` VALUES (4,'something cirocco', 'ttp://ww.roccoh.t/','',16,'something.','',86,0,1,1,'',0,'achille',1259843781,1259843781,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (5,'somethingasco','htp://w.vsco.b/ge/gtpage.asp?i=0','',16,'somethingsco','sco',113,0,1,1,'',0,'achille',1259843935,1259843935,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (6,'something','http://w.ja.b/Default.aspx','',16,'somethingaga','',62,0,1,1,'',0,'achille',1259848860,1259848860,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (7,'something','htp://w.arkorrier.com.tr/English/AC_urun.asp?ID=ACU36#','',16,'','',90,0,1,1,'',0,'achille',1259848962,1259848962,2714,0,0,'91.132.75.249',0,0,0,'');
-- omitted
/*!40000 ALTER TABLE `adv_links` ENABLE KEYS */;
UNLOCK TABLES;
我问这个是因为当到达 /*!40000 ALTER TABLE adv_link ENABLE KEYS */;
行时,MySQL 会按排序修复索引,它可以'找不到足够的空间,因为数据集太大,排序时会在 tmpdir
中堵塞。
Let me rephrase the question:
Is it vital for the /*! */
lines, in the SQL file below, to exist when inserting data using individual INSERT statements?
This is the contents of the file now:
LOCK TABLES `adv_links` WRITE;
/*!40000 ALTER TABLE `adv_links` DISABLE KEYS */;
INSERT INTO `adv_links` VALUES (13,'photoreal','http://w.otoreal.tk','',14,'something','something, something',64,0,1,1,'',0,'',1277754393,1277754393,0,0,0,'85.72.100.18',0,0,0,'');
INSERT INTO `adv_links` VALUES (4,'something cirocco', 'ttp://ww.roccoh.t/','',16,'something.','',86,0,1,1,'',0,'achille',1259843781,1259843781,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (5,'somethingasco','htp://w.vsco.b/ge/gtpage.asp?i=0','',16,'somethingsco','sco',113,0,1,1,'',0,'achille',1259843935,1259843935,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (6,'something','http://w.ja.b/Default.aspx','',16,'somethingaga','',62,0,1,1,'',0,'achille',1259848860,1259848860,2714,0,0,'91.132.75.249',0,0,0,'');
INSERT INTO `adv_links` VALUES (7,'something','htp://w.arkorrier.com.tr/English/AC_urun.asp?ID=ACU36#','',16,'','',90,0,1,1,'',0,'achille',1259848962,1259848962,2714,0,0,'91.132.75.249',0,0,0,'');
-- omitted
/*!40000 ALTER TABLE `adv_links` ENABLE KEYS */;
UNLOCK TABLES;
I am asking this because when reaching the /*!40000 ALTER TABLE adv_link ENABLE KEYS */;
line, MySQL goes and repairs the index by sort and it can't find enough space since the dataset is large enough to choke in the tmpdir
while sorting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不禁用并重新启用密钥,密钥将随着每个
INSERT
语句动态更新(就像通常一样)。这不需要写入
tmpdir
,但速度较慢。如果您无法增加
MySQL
使用的临时空间,您可以删除这些行,但这会减慢导入速度。If you don't disable and re-enable your keys, the keys will update dynamically with each
INSERT
statement (as they normally do).This does not require writes to
tmpdir
, but is more slow.You may drop these lines if you cannot increase temporary space used by
MySQL
, though it will slow down your import.