How should I handle measurement errors in a timeseries database? I have a table used to record measurements sampled at regular intervals on different sensors. Each row records the time, the identifier of the quantity being measured, and the value itself.

Now and again measurement errors occur and garbage is being recorded in the value field. How should I deal with these errors:


Delete the offending rows entirely, losing the information that there had been an error;
Keep the row as is, and asking of client code to deal with the errors;
Replace the values with NULL, losing the original erroneous value?


Or is there another option that I have not considered?
I would keep the data, if at any point in the future you want to find out what was wrong with it you still have it.

It can provide you with some information later on about how often measurements fail, where they originate from, what the offset is and things like that.

Deleting the data is unrecoverable, handling them in some way can always be changed later on. For example you could handle them in your client application for now and if you have some issue with that store them physically in a table_cleaned table.

If you deleted them or replaced them with NULL the information is gone for good.