[英]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.