Note that there are some explanatory texts on larger screens.

plurals
  1. POSUM of history table in database to show user's total credit (reputation)
    primarykey
    data
    text
    <blockquote> <h3>Explanation:</h3> </blockquote> <ul> <li>I have an script which shows total credits(reputation) for each user and it has a history table in database for earned credits of all uesrs</li> </ul> <p>Here is a sample of my History Database Table:</p> <pre><code> +----------------------------------------------+ | DATE ID USERNAME CREDITS | +----------------------------------------------+ | ... 1 X 12 | | ... 2 E 2 | | ... 3 X 1 | | ... 4 X -7 | | ... 5 O 4 | +----------------------------------------------+ </code></pre> <ul> <li>My Script uses SELECT SUM FROM table WHERE username='X' and echoes it, so in this case for user X (12 + 1 - 7) it echoes 6</li> </ul> <hr> <blockquote> <h3>Questions:</h3> </blockquote> <ol> <li><p>I wanted to know isn't this (<strong><em>SELECT SUM of all history</em></strong> to show a users credit <strong>INSTEAD</strong> of <strong><em>having a different table for total credids of users</em></strong>) going to make problems if the history table is so huge? (lets say +100,000,000 records after a few years)</p></li> <li><p>Is this what most of professional programmers do? (if not, what is)</p></li> <li><p>What about the history section, if users want to review credits history should we LIMIT it with like <strong><em>LIMIT 100</em></strong> records when *<em>SELECT</em>*ing or no (for performance)</p></li> <li><p>Is this supposed to run on each page refresh or each page change? (if 1000 users are online and this SELECT query is applied on each refresh doesn't it slow down the server)</p></li> </ol> <blockquote> <p><strong>EDIT After an answer:</strong></p> </blockquote> <p>But if we have to keep totals in a different table and update them automatically there are two problems:</p> <ol> <li><p>If we do it exactly when user have received some credits isn't it possible user have received two different credits at exactly the same time (it is possible), and as we can't put Auto Increment in Totals table (because each user only have 1 record) we might miss 1 credit, <strong>Or if there is a solution for this problem, i am not aware of that</strong></p></li> <li><p>If we set a Cron-Job to do it frequently, then the user credits are not up to date until cron job refreshes the totals table</p></li> </ol>
    singulars
    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.
 

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