MYISAM表插入速度慢
我需要创建一个包含两个属性的表:id 和 author。这两个属性形成复合键。此外,我需要对 author 字段执行索引搜索。 因此,我使用以下语句创建表:
CREATE TABLE IF NOT EXISTSauthors (author VARCHAR(100) NOT NULL, id VARCHAR(200) NOT NULL, INDEX USING BTREE(author,id), PRIMARY KEY (author,id))引擎=MYISAM;
现在,当我尝试使用 JDBC 插入大约 450 万条记录时,最后插入速度变得非常慢。 id 属性指的是相关作者创建的出版物。一位作者与多个 ID 相关,反之亦然。相同 id 值的平均数量低于相同author 值的数量。 因此,我使用交换的属性测试了相同的过程。在这种情况下,插入速度几乎保持恒定。 有没有办法优化表以获得性能? 我不太清楚 MYISAM 如何管理索引组合键。可能是平衡过程的原因...
提前致谢!
I need to create a table containing two attributes: id and author. These two attributes form the composite key. Moreover I need to perform an index search on the author field.
Therefore I create the table using the following statement:
CREATE TABLE IF NOT EXISTS authors (author VARCHAR(100) NOT NULL, id VARCHAR(200) NOT NULL, INDEX USING BTREE(author,id), PRIMARY KEY (author,id)) ENGINE=MYISAM;
Now, I when try to insert about 4.5 million records using JDBC, the insertion speed gets terribly slow at the end.
The id attribute refers to a publication which was created by the related author. One author is related to several ids and vice versa. The average number of identical id values is lower than the number of identical author values.
Therefore I tested the same procedure with swapped attributes. In this case, the insertion speed remains nearly constant.
Is there a way to optimize the table in order to gain performance?
I don't quite know how MYISAM manages indexing composite keys. May be the process of balancing is the reason...
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我注意到一些问题:
在这些更改之后,您的索引将位于简单的数字类型上,并且插入速度应该很好。
I notice a few problems:
After these changes, your index will be on simple numeric types and your insert speed should be good.