I think any of your suggestions in the question is appropriate.
Depending on how you use this, you can save time by running INSERT IGNORE, which allows you to insert a new row if the primary key does not exist. If it exists, the error is ignored, so you can continue as usual.
Other similar options, depending on your use, include using the REPLACE or INSERT ON DUPLICATE KEY UPDATE insert types. This allows you to update an existing record if the primary key already exists, otherwise it simply inserts a new record.
source share