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 7825641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:05:39+00:00 2026-06-02T09:05:39+00:00

In order to determine how often some object has been used, I use a

  • 0

In order to determine how often some object has been used, I use a table with the following fields;

id - objectID - timestamp

Every time an object is used, it’s ID and time() are added in. This allows me to determine how often an object has been used in the last hour/minute/second etc.

After one hour, the row is useless (I’m not checking above one hour). However, it is my understanding that it is unwise to simply delete the row, because it may mess up the primary key (auto_increment ID).

So I added a field called “active”. Prior to checking how often an object has been used I loop over all WHERE active=1 and set it to 0 if more than 1 hour has passed. I don’t think this would give any concurrency problems between multiple users, but this leaves me with alot of unused data.

Now I’m thinking that maybe it’s best to, prior to inserting new usage data, check if there is a field with active=0 and then rather than inserting a new row, update that one with the new data, and set active to 1 again. However, this would require table locking to prevent multiple clients from updating the same row.

Can anyone shed some more light on this, please?

  • 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-06-02T09:05:40+00:00Added an answer on June 2, 2026 at 9:05 am

    I’ve never heard anywhere that deleting rows messes up primary keys.

    Are you perhaps attempting to ensure that the id values automatically assigned by auto_increment match those of another table? This is not necessary – you can simply use an INTEGER PRIMARY KEY as the id column and assign the values explicitly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an if statement in order to determine if an element has any
I would like to use SevenZipSharp in order to determine if a file is
In order to determine the size of the column in C language we use
In order to determine what low-level framework types a web application is directly using,
Order by descending is not working on LINQ to Entity In the following Query
Order props: Object selectedItems: Array[1] 0: SelectedItem length: 1 __proto__: Array[0] __proto__: Order I
I'm using Control.PreferredSize in order to determine what the ScrollableControl.AutoScrollMinSize should be for a
I have managed to override a controls WindowProc function in order to determine more
Often i have a problem that I need to determine which assebmly to include
Currently it seems common practice to parse Postfix log files in order to determine

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.