Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted April 3, 20169 yr Is there a core table that counts and stores numbers like Member Count, Post Count, Topic Count?
April 4, 20169 yr Queries are on widgets and they are updated at every 60 seconds (or more, depending on your setting). Forums stats, for example: $stats = array(); $stats['total_posts'] = \IPS\Db::i()->select( "COUNT(*)", 'forums_posts', array( 'queued = ?', 0 ) )->first(); if ( \IPS\Settings::i()->archive_on ) { $stats['total_posts'] += \IPS\forums\Topic\ArchivedPost::db()->select( 'COUNT(*)', 'forums_archive_posts', array( 'archive_queued = ?', 0 ) )->first(); } $stats['total_topics'] = \IPS\Db::i()->select( "COUNT(*)", 'forums_topics', array( 'approved = ?', 1 ) )->first();
May 26, 20168 yr I've tried using these queries to acquire the forum stats for use on another page of the site however the query that counts the total number of posts started to queue up in the database server almost immediately and ground the site to a halt - it's simply too resource intensive to keep recounting such a large table. Is there nowhere in the database where these forum statistics are cached ? Surely the forum doesn't recount them every time someone views the forum stats widget ?
Archived
This topic is now archived and is closed to further replies.