I am storing data on an interval basis (gps location) and I dont want the DB to swell up so I defined a MAX number of lines it can go up to and then it simply deletes the oldest line every time I insert a new one.
Now a database expert looked at my code and he says its way not efficient because deleting a row from the database is the most time/memory/procedures consuming action and I should avoid it at all cost.
He says I should instead, run-over the oldest line (update) after I reach MAX.
(so it goes top to bottom every time)
That means I need to save a separate “header” table to save my current pointer to the oldest line and update it on every insert (i don’t want to lose it if the app crashes) ..
does it really more efficient ? any other ways to do this more efficiently?
Turning your database table into a ring buffer is silly.
If you really want to use this approach…
———-gps.dat———-
When you want to add a record: