I have this situation here.
- An auction system listing orders that are “active” (their deadline didn’t occur yet)
- There is a lot of orders so it is better to have a field “active” instead of listing them based on time queries
I’m not a database expert, just a user. What is the best way to implement this scenario ?
- Do I have to manually check the “deadLine” field and change “active” status every once in a while ?
- Is Mysql able to change the field automatically ?
- How demanding are queries of type “select orders where “deadline” has passed “
- Is it better to use boolean criterion or timestamp criterion for searching ? it’s like 0,05% active 9,95% passive entries
Finally I have to move old order entries to a different backup table. My point is make the table lightweight, because there could be many requests per second. I’m not sure how much load does it put on the database, whether it there is a difference between criterion like boolean and time for searching
It sounds like you’re going to an awful lot of work to solve a problem there’s no evidence that you have. Especially if you’re going to be archiving older records off, why don’t you make sure that you can’t do the time-based searches before you create an entire system dedicated to maintaining a second column that performs the same function as the time column.
If you do decide that you need to keep a separate list of active auctions consider doing it not with a special column (and largely wasted index) but rather by creating an active_auctions table that contains only the primary key column(s) from auctions. Add a row to this table for each auction that becomes active and delete it when it becomes inactive. JOIN this table to the main auction table for a list of currently active auctions.