I have an application that inserts single data in the MYSQL db. However, if the data exists, I will not update/insert the record anymore; just discard the data
Do you think which is efficient between the two:
1. Directly execute insert statement then just put a catch clause to catch duplicate primary key exception
2. Execute a select statement first to find if primary key exists in DB then if not, execute insert.
I think option 2 is more cleaner but I want to know which is more efficient.