April 3, 2016 in Technical Problems
Is there a core table that counts and stores numbers like Member Count, Post Count, Topic Count?
Any ideas or is this just queried on the fly every time?
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();
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 ?
This topic is now archived and is closed to further replies.
Started 5 hours ago
Started 13 hours ago
Started Saturday at 04:16 PM