How often to write in database

Hi,
I am working on a project where the player collects coins (mario style). I would like to write how many coins the player has earned in a database. Do i do that every time i collect a coin (which is pretty often, like every second) or? Is this a slow process? Is it a mistake/bad style of programming? Whats the solution for that?
Hilfe <3

Is it an online database? If not it wouldn’t be that hurtful to update the database every second because the only update that database gets is from you and not other players.

Store the score on a variable, then pass this to the databse.
Almost all the games are like this, if ur computer shuts down on the half of the way, you’ll lose all your achievements.

Depends on how often you need it to be updated. If it’s a real time multiplayer game, and you need everyone to see what the player has collected, then yes, you will need to write every coin collection. However, if you need to complete a level, then it’s best you write the score to a variable you will send to your database once the level is complete.

At this point, however, I don’t think you have to worry about such microoptimization - usually it’s only important on big scales and on SSDs on servers, which you don’t seem to be using yet. Writing is not a very complex operation, anyways.