15 years on The Web
miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Suggestions miniBB Support Forums / Suggestions /   

counting (db_calcAmount)

Author Anonymous
#1 | Posted: 19 Aug 2005 23:03 
I think...

if($user_id!=0) mysql_query('UPDATE '.$Tu.' SET num_topics=num_topics+1 WHERE user_id = '.$user_id.' LIMIT 1');

... is better than ...

//if($user_id!=0) db_calcAmount($Tt,'topic_poster',$user_id,$Tu,$dbUserSheme['num_topics '][1],$dbUserId);

(i'm creating a populate_num_fields.php as i'm an older version's user)

Author Team
#2 | Posted: 19 Aug 2005 23:48 
So, why better?

I think it is only a little bit slower, but making posts is itself a slow operation, so adding a couple of bits here doesn't really make sense.

On another hand, count()+update is more stable - what if admin deletes some users message at this time? What if there was some hang up in database, and you some of records were discounted?.. And, for example, I saw a board which lost part of its records during HDD crash. User posts were lost partially, but not re-calculated in database. In our case, recalculation takes time always. Additionally, you may program and advance this function easily, if you are making some operations based on user's posts amount (for example, are giving him points).

FIELD=FIELD+1 in most cases is more weak in this case.

Author Anonymous
#3 | Posted: 23 Aug 2005 16:10 
So, why better?

1 query only! =)

I think it is only a little bit slower,

My posts table is 465MB large, 1,722,438 records ar this time. With the count statement it gets more slow.

is more stable

Yes. But if admin operations recalculates the whole stats i think we can get a stable and faster system.

Another suggestion: Other thing i saw can be improved is the antispam: we can remove the count "column" from the query, add a "LIMIT 1" statement and analyse the result with mysql_num_rows.

Author Team
#4 | Posted: 23 Aug 2005 16:27 
Ok, we will discuss your suggestions. Thanks.

Suggestions miniBB Support Forums / Suggestions / counting (db_calcAmount) Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.

Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB