Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:19:06+00:00 2026-05-30T22:19:06+00:00

I am storing data on an interval basis (gps location) and I dont want

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:19:07+00:00Added an answer on May 30, 2026 at 10:19 pm

    Turning your database table into a ring buffer is silly.
    If you really want to use this approach…

    • Don’t use a database just use a data file and IO
      • In your data file each record will be a fixed size
        • [Time Stamp][Latitude][Longitude]
        • You can use string formatted or binary representations of your data it doesn’t matter as long as they are fixed size.

    ———-gps.dat———-

    [Ring Pointer]
    [Time Stamp][Latitude][Longitude]
    [Time Stamp][Latitude][Longitude]
    ...
    [Time Stamp][Latitude][Longitude]
    
    • Ring Pointer is the binary representation of a long integer
    • When you first create the file you’ll set its size to the size of an LONG_INTEGER_SIZE + (MAX_RECORDS * RECORD_SIZE)

    When you want to add a record:

    • Read [Ring Pointer] from the beginning of the file
    • Write [Ring Pointer] + 1 to the beginning of the file (so people don’t get confused keep the [Ring Pointer] variable the same just write the new value back to the file)
    • Go to location LONG_INTEGER_SIZE + (([Ring Pointer] % MAX_RECORDS) * RECORD_SIZE)
    • Write your new record at that location
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In which cases storing data as XML is preferable to RDBMS and why? Can
I often find myself storing data in a mysql database, and then wanting to
I'm storing data on baseball statistics and would like to do so with three
I am using Microsoft Access database for storing data. In that, I stored date
Does anyone have any experience of storing data in JavaScript across all mobile platforms
I am writing a program using Delphi 2006 and storing data in XML files
When is it appropriate to store data in HttpContext.Current.Items[...] vs storing data in ViewData[...]
Possible Duplicate: HTML5 local storage sort I am storing data into a localstorage using
I'm doing a Java software-project at my university that mainly is about storing data-sets
I just noticed this about a week ago. I'm storing data about the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.