Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can think of a few options off the top of my head here:</p> <ol> <li><p>As you mentioned, total up the reputation points earned during the time range and calculate the percentile ranks based on that.</p></li> <li><p>Track updates to reputation_total on a daily basis - so you have a table with user_id, date, reputation_total.</p></li> <li><p>Add some new columns to the user table (reputation_total, reputation_total_today, reputation_total_last30days, etc) for each time range. You could also normalize this into a separate table (reputation_totals) to prevent you from having to add a new column for each time span you want to track.</p></li> </ol> <p>Option #1 is the easiest, but it's probably going to get slow if you have lots of rows in your reputation transaction table - it won't scale very well, especially if you need to calculate these in real time.</p> <p>Option #2 is going to require more storage over time (one row per user per day) but would probably be significantly faster than querying the transaction table directly.</p> <p>Option #3 is less flexible, but would likely be the fastest option.</p> <p>Both options 2 &amp; 3 would likely require a batch process to calculate the totals on a daily basis, so that's something to consider as well.</p> <p>I don't think any option is necessarily the best - they all involve different tradeoffs of speed/storage space/complexity/flexibility. What you do will ultimately depend on the requirements for your application of course.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload