miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Suggestions miniBB Support Forums / Suggestions /  
 

counting (db_calcAmount)

 
Author Anonymous
Guest
#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
8-)
#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
Guest
#3 | Posted: 23 Aug 2005 16:10 
Team
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.
really.

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
8-)
#4 | Posted: 23 Aug 2005 16:27 
Ok, we will discuss your suggestions. Thanks.

Suggestions miniBB Support Forums / Suggestions /
 counting (db_calcAmount)
 Share Topic's Link

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


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑