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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:11:53+00:00 2026-05-22T17:11:53+00:00

Basically, I have a table called event: id | title | countdown | description

  • 0

Basically, I have a table called event:

id | title | countdown | description | active | expired | created_at | updated_at

I was starting to concept how to create “LIVE” events using MySQL or PHP. So I was thinking I could use either a Cron referencing PHP or an event using straight SQL.

So my ideas were the following:

Restructure my tables to:

events:
id | title | description | created_at | updated_at

event_queue:
id | event_id

active_events:
event_id | countdown | iteration

expired_events:
event_id | expired_at

So having that, how can I create a live timer to run every second to update, at most, 100 rows in active_events every second?

Example data to go inside active_events is as follows:

event_id: 1,
countdown: 20 (for 20 minutes),
iteration: 90

I want to decrement countdown every second and when it hits 0, to decrement the iteration and start the countdown back to 20. Once the iteration is at 0 and countdown is at 0, just remove the entry completely, then archive the event to expired_events. Again, only a max of 100 rows will be inside active_events.

What’s the best way to go about doing this?

Basically this is an internal application that people can vote on in the office and if no votes are done, then it goes away. The above structures are how I want it and see it working.

Any thoughts? (I have to go to lunch and will update this or leave comments on any posts later)

EDIT:
Back from lunch!… I forgot to note that the countdown needs to reset every time an action is placed on it (a user votes on it). For the sake of my brain and thinking, let’s say every time someone accepts one of the events, it is stored into accepted_events, and the active_events countdown has to be reset to 20.

Here is my server’s top running the MySQL event and not:

RUNNING IN VM INSTANCE ON MACBOOK PRO

This is without the event

top – 11:56:59 up 1:29, 1 user, load average: 0.11, 0.06, 0.01
Tasks: 92 total, 2 running, 88 sleeping, 2 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st
Mem: 510552k total, 499364k used, 11188k free, 74316k buffers
Swap: 1048568k total, 0k used, 1048568k free, 251872k cache

This is with the event scheduled and running the following SQL on 200 rows:

update test set timer = timer-1

top – 12:00:08 up 1:32, 1 user, load average: 0.06, 0.04, 0.00
Tasks: 92 total, 2 running, 88 sleeping, 2 stopped, 0 zombie
Cpu(s): 0.3%us, 0.3%sy, 0.0%ni, 99.0%id, 0.0%wa, 0.3%hi, 0.0%si, 0.0%st
Mem: 510552k total, 501720k used, 8832k free, 74996k buffers
Swap: 1048568k total, 0k used, 1048568k free, 253244k cached

EDIT # 2: Here’s a sketch of what I mean — http://oi51.tinypic.com/29c1bp4.jpg

  • 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-22T17:11:53+00:00Added an answer on May 22, 2026 at 5:11 pm

    I ended up creating a script that runs every second and updates a small table. I have about 2.5 million unique daily views on my server and I barely saw a performance hit doing so.

    I just have a table of 200 records that I decrement the values every second.

    timer | location_id | queue_id
    

    If the record hits 0, grab the next queue_id and insert it into there then reset the timer… I’ll think of another way to do this later, for now, i’m not seeing a bad performance hit at all… If I need to, I can just have my own server / database for this.

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

Sidebar

Related Questions

I have a History Table in SQL Server that basically tracks an item through
Can we have a SQL query which will basically help in viewing table and
I have a table called People with a columns of datatype xml called properties
I have a table called People one of the columns is an xml field
I have a table called Subscriptions. I'd like to redirect any LINQ select from
I have a table called tbl_users A broken down version of it for this
I basically created some tables to play around with: I have Two main tables,
I basically have a page which shows a processing screen which has been flushed
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp
I am looking in to ways to enable a site to basically have something

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.