MongoDB query ranking

  mongodb, question

Overview: 7 million college students in the national college entrance examination results ranking query

Details: A data table stores 7 million examinee performance data. Candidates can query the total performance and ranking by entering the admission ticket number. How can this requirement be optimally realized?

Data table fields: admission ticket number, Chinese, mathematics, English, comprehensive, total score, name, student number

I understand the following requirements:

  1. The inquiry is only based on the admission ticket number.
  2. Admission tickets are unique;
  3. The results of each return need to return the total score and ranking.
  4. The frequency of performance changes is not high, and the later the time, the lower the frequency.

Implementation ideas:

  • The admission ticket number establishes a unique index, so the inquiry is very fast, in millisecond level.
  • Write a service separately and calculate its ranking according to the total score recorded. This kind of query is the most efficient. Maintenance is more troublesome. We should also take into account the fact that the results have changed and the ranking has not changed.
  • Or dynamically query ranking every time, which is simple and efficient (for 700W data). There will be no synchronization between results and rankings.