Open elacour opened 1 year ago
Ideally, yes. However, to know if a setting exists (keep in mind that another user could be modifying at the same time), you need to query first and then update. Another option is to use the INSERT ... ON DUPLICATE KEY UPDATE that MySQL supports. However, SQLite uses something different (INSERT OR REPLACE) as does PostgreSQL. A final option would be do always do UPDATE and catch Exceptions where an INSERT could happen...
In any event, I've got a 3 year-old Intel i5 that saves all the settings in less than a second. And most users don't actually save settings that many times. So, I'm happy to take code contributions. But, this seems like a lot of trouble to go through for a very small performance boost.
Updating a system setting is very slow. Looking at the DB, seems that every configuration value leads to a DELETE followed by an INSERT, the modified and not modified ones.
Only updated settings should be updated in database.