Limiting the number of records in a Sqlite DB
What I'm trying to implement here is a condition wherein a sqlite database
holds only the most recent 1000 records. I have timestamps with each
record. One of the inefficient logic which strikes right away is to check
the total number of records. If they exceed 1000, then simply delete the
ones which fall out of the periphery.
However, I would have to do this check with each INSERT which makes things
highly inefficient.
What could be a better logic? Can we do something with triggers?
Some related questions which follow the same logic I thought of are posted
on SO:-
Delete oldest records from database
SQL Query to delete records older than two years
No comments:
Post a Comment