Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Homepage Statistics Cache Details »»
Homepage Statistics Cache
Version: 1.00, by Tigga Tigga is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.3.x Rating:
Released: 04-03-2003 Last Update: Never Installs: 31
 
No support by the author.

A little while ago I ran into this problem... I like having a lot of statistics on my forum's homepage, but I don't like having a lot of queries on that page. That got me to start thinking of a better way to do it, hence the creation of this hack.

How does this hack work?
It's pretty simple really. Instead of counting every single thread, post, member and etc every time someone loads your forum, it only counts these after a specified amount of time and updates one table that the information will be pulled from. This hack is especially useful for high traffic sites and can reduce the time it takes to load your forum's homepage.

Statistics Included:
Total Threads
Threads Today
Total Posts
Posts Today
Total Members
Newest Member
Top Poster
Top Thread Starter
If you are an admin, it will show you the last time the stats were updated as well.

(Please note that some of these started as hacks from other members at vB.org. Most of them are so simple though I don't see much of a point in trying to figure out which one's I got from here X months ago. If your hack was included here and you would like credit given please post here and I will add it.)

Normally these stats would add 8 queries to your forum's homepage. With this hack installed it will only perform 1 query most of the time, and 9 queries when it needs to update the information. I have found this very useful to cut down on the number of queries on my homepage, decrease the page's loading time, and put less overall stress on my server.

Well that's about it. I hope some others will find this hack useful and if anyone has some suggestions for other stats they would like to include in the stats cache please let me know and I will try to implement them.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 05-19-2003, 02:09 PM
corsacrazy's Avatar
corsacrazy corsacrazy is offline
 
Join Date: May 2002
Location: london
Posts: 854
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^ much better cheers
Reply With Quote
  #53  
Old 05-19-2003, 08:03 PM
Crazy Pete Crazy Pete is offline
 
Join Date: Nov 2002
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't figure out how to get Link14716's Newest Member's First Post! (v1.1) to work with this hack. It shows the member's first post for the first 10 minutes until the cache updates again, then it disappears and seems to pop back in at random. Any ideas? The query for the post is...
Code:
// get newest user's first post
if ($getnewestusers['lastpost']!=0){
$getnewusersposts=$DB_site->query_first("SELECT * FROM post WHERE userid=$newuserid LIMIT 1"); 
 $userfirstpost=$getnewusersposts['postid']; 
 
 if (!$getnewusersposts) {
 $firstpost="";
 } else {
 $firstpost=" | <a href='showthread.php?postid=$userfirstpost#post$userfirstpost'>First Post!</a>";
 }
}
Reply With Quote
  #54  
Old 05-31-2003, 06:09 PM
Crazy Pete Crazy Pete is offline
 
Join Date: Nov 2002
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No one?
Reply With Quote
  #55  
Old 05-31-2003, 07:23 PM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry Crazy Pete, for some reason I don't think I got email notification the first time you replied to this. To get that to work with the cache you will have to add some extra fields to the statscache table that can be updated. Or to just get it to work properly without being cached you would need to make sure your code isn't in the part where it gets the information for the cache. If you look for this code:
$statsupdate = '';
And put your code for the newest member's first right above that it should work fine.
Reply With Quote
  #56  
Old 05-31-2003, 07:29 PM
Crazy Pete Crazy Pete is offline
 
Join Date: Nov 2002
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Tigga, I'll try that and see if it solves the problem.
Reply With Quote
  #57  
Old 08-03-2003, 10:18 PM
Lethal Lethal is offline
 
Join Date: Feb 2002
Location: PA/USA
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sometimes my (total) # of users don't show up. The active users show up all the time but my total users don't. Just everyone once and awhile they do which is weird becuase if they show up once, shouldn't they show up all the time?
Reply With Quote
  #58  
Old 08-03-2003, 10:50 PM
Till Till is offline
 
Join Date: May 2002
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://0x00.org/php/phpCache/" target="_blank">http://0x00.org/php/phpCache/</a>

I use this one to cache various things on our forums. For example, all the forum jump dropdowns (yeah, how often do you modify your forums, yet this is pulled from the database on nearly every page).
Reply With Quote
  #59  
Old 10-08-2003, 10:36 AM
blakkboy's Avatar
blakkboy blakkboy is offline
 
Join Date: Aug 2003
Location: Baltimore
Posts: 251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i followed the directions and this is what i got
Reply With Quote
  #60  
Old 10-09-2003, 03:43 AM
futureal futureal is offline
 
Join Date: Feb 2002
Location: Del Mar, CA, USA
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Out of curiosity, instead of updating every 10 (or however many) minutes, why not just create a cache table in your database and then update it whenever actions take place? That way, you still get "real time" stats but you still only need a single query on forumhome.

For example, you could:

- update cache whenever a post is made (posts today, total posts)
- update cache whenever a thread is started (total threads, total posts, posts today)
- update cache whenever someone registers (total members, newest member)

...and so on and so forth.

Is it just too much of a pain to implement it that way, or is there something else I am missing?

I like the idea of caching stats, but I am also bent on getting real-time stats.
Reply With Quote
  #61  
Old 10-13-2003, 02:59 AM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well part of the point of this hack is to help decrease strain on the server. If you're updating that table every time a post/thread is made, a new user joins, and etc then that's quite a few more queries to the database. If you're that bent on getting real-time stats that method would work and your forum homepage would load quicker with all the stats, but it would be hard to tell if it would be any better or worse on your server...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:40 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04781 seconds
  • Memory Usage 2,306KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete