Skip to main content
caveat
Source Link
Rick James
  • 79.4k
  • 5
  • 51
  • 117

Since recalculating rankings for a large table can take a long time, and doing that frequently can mean a really long time, start with this question:

  1. Will the recalculating during SELECT be "fast enough"? If the answer to this question is 'yes', then simply do it.

  2. Will the recalculation will be "fast enough" to do during INSERTs. Also, ask whether the burden on the system is "too much". If this is OK, then simply do it.

  3. If both of those don't pass muster, periodically recompute the rankings.

Note that MySQL 8.0 and MariaDB 10.2 have ranking and other "windowing functions". However, you need to test them -- they may not be "fast enough"; after all 'ranking' probably requires reading and sorting the entire table.

Since recalculating rankings for a large table can take a long time, and doing that frequently can mean a really long time, start with this question:

  1. Will the recalculating during SELECT be "fast enough"? If the answer to this question is 'yes', then simply do it.

  2. Will the recalculation will be "fast enough" to do during INSERTs. Also, ask whether the burden on the system is "too much". If this is OK, then simply do it.

  3. If both of those don't pass muster, periodically recompute the rankings.

Note that MySQL 8.0 and MariaDB 10.2 have ranking and other "windowing functions".

Since recalculating rankings for a large table can take a long time, and doing that frequently can mean a really long time, start with this question:

  1. Will the recalculating during SELECT be "fast enough"? If the answer to this question is 'yes', then simply do it.

  2. Will the recalculation will be "fast enough" to do during INSERTs. Also, ask whether the burden on the system is "too much". If this is OK, then simply do it.

  3. If both of those don't pass muster, periodically recompute the rankings.

Note that MySQL 8.0 and MariaDB 10.2 have ranking and other "windowing functions". However, you need to test them -- they may not be "fast enough"; after all 'ranking' probably requires reading and sorting the entire table.

Source Link
Rick James
  • 79.4k
  • 5
  • 51
  • 117

Since recalculating rankings for a large table can take a long time, and doing that frequently can mean a really long time, start with this question:

  1. Will the recalculating during SELECT be "fast enough"? If the answer to this question is 'yes', then simply do it.

  2. Will the recalculation will be "fast enough" to do during INSERTs. Also, ask whether the burden on the system is "too much". If this is OK, then simply do it.

  3. If both of those don't pass muster, periodically recompute the rankings.

Note that MySQL 8.0 and MariaDB 10.2 have ranking and other "windowing functions".