English 中文(简体)
MySQL和用户参考书表更新?
原标题:MySQL and Scheduled Updates by User Preference?

I m 提出申请

  • stores an e-mail address (to a user) in a table.
  • stores the number of days the user would like to stay in the table.
  • takes the user off the table when the number of days is up.

我并不真正知道如何处理这一问题,因此我的问题是:

  1. Each second, do I have the application check through every table entry for the time that s currently stored in, let s say, the time_left column?
  2. Wouldn t (1) be inefficient if I m expecting a significant number (10,000+) users?
  3. If not (2), what s the best algorithm to implement for such a task?
  4. What s the name of what I m trying to do here? I d like to do some more research on it before and while I m writing the script, so I need a good search query to start with.

我计划用Perl语撰写这一文字,尽管我愿意接受有关语言选择、框架等的建议。 我实际上对网络发展(后端和前端)来说是新的,因此,如果你能够向我提供准确的咨询意见,我会不胜感激。

谢谢!

* 在张贴之后,。 询问一个有效问题:

Why would you store users if they won t get requested?

用户刚刚在数据库中开庭。

从用户输入数据库后每5分钟使用用户电子邮件地址说一米(如果用户条目在2:00PM-10月18日出生,用户可在2:05、2:10等查询)。

如果用户在10天内决定希望从数据库中删除,这意味着其输入通常(每5分钟从2:00PM-October 18)到2:00PM-October 28。

So to clarify, based on this situation:

www.un.org/Depts/DGACM/index_spanish.htm 该系统必须不断将目前的时间与用户的到期日期进行比较?

最佳回答

You could write a separate program/script which makes the delete query on a set interval. If you are on a Linux machine you can create a cron job to do it. Doing it every second may become very resource intensive for slower machines and larger tables, but I don t believe that will become an issue for a simple delete query.

问题回答

您不应储存时间——电子变数,否则就应当储存。 这样,只要用户要求数据库,你就可以检查其是否有效。

否则,你会想做什么。

这种做法使你能够做任何工作,或者将给你带来额外负担。

Hey Mr_spock I like the above answer from Topener. Instead of storing a number of days the user would like to be valid, store the day the user would like to be be removed.

Adding a field like validToDate, which would be a DATETIME field type, you can do a query like

delete from tablename 地点validToDate <= NOW()

地点

  • the italicized text is a SQL query
  • tablename is the name of the table in question
  • NOW() is a valid sql function that returns the current DATETIME
  • validToDate is a field of type DATETIME

有了效率高的服务器的承诺,我认为这相当好。





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签