繁体   English   中英

主外键减慢InnoDB插入速度

[英]Primary Foreign Key slowing down InnoDB inserts

我要导入很多(仅约10,000名)员工,然后立即将其全部设为用户帐户。 插入到我的user_profile表中会减慢一切速度,因为该表的主键也是外键,而不是通常的自动增量ID。

有什么办法可以加快速度吗? 还是我需要返回并以某种方式将自动增量ID添加到user_profile?

编辑:

user:
  id
  username
  salt
  password

user_profile:
  user_id -> Primary Key and Foreign Key to user table
  first_name
  last_name
  email
  ...

我的建议是将一个id字段添加到user_profile表中,使其成为主键(unsigned和auto_increment)。 然后,将user_id字段作为用户( id )表的外键。 我从未见过字段充当另一个表的主键和外键。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM