PDA

View Full Version : Board Optimization - (Forumdisplay) Turn off announcements & save 1 query


ThorstenA
01-09-2007, 10:00 PM
(Forumdisplay) Turn off announcements & save 1 query



What does this product do?

This very easy to use product turns off announcements in forumdisplay and saves a whole query each time forumdisplay is presented. Therefore it improves forum speed. There is a discussion in suggestion forum of vbulletin.com (http://www.vbulletin.com/forum/showthread.php?t=212795) to only search for new announcements once a day instead of searching for new announcements each time forumdisplay is presented.

Installation information

Files edited: 1
Templates edited: 0
Files to upload: 0
DB Tables changed: 0
Additional queries: 0
Changed queries: 0
Time to install: 60 seconds max


Installation


Open forumdisplay.php

Search for

$announcements = $db->query_read_slave("
SELECT
announcement.announcementid, startdate, title, announcement.views,
user.username, user.userid, user.usertitle, user.customtitle, user.usergroupid,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
" . (($vbulletin->userinfo['userid']) ? ", NOT ISNULL(announcementread.announcementid) AS readannounce" : "") . "
FROM " . TABLE_PREFIX . "announcement AS announcement
" . (($vbulletin->userinfo['userid']) ? "LEFT JOIN " . TABLE_PREFIX . "announcementread AS announcementread ON (announcementread.announcementid = announcement.announcementid AND announcementread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = announcement.userid)
WHERE startdate <= " . TIMENOW . "
AND enddate >= " . TIMENOW . "
AND " . fetch_forum_clause_sql($foruminfo['forumid'], 'forumid') . "
ORDER BY startdate DESC, announcement.announcementid DESC
" . iif($vbulletin->options['oneannounce'], "LIMIT 1"));

Delete this code

Save forumdisplay.php




Flagged for future version


Put an IF { } statement around this, and create a new setting in vBulletin Options to control whether the Announcement is on or off in Forumdisplay.


Please click Install (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=136134) if you installed this product. So you can get information if product improves. Thank you.



This hack may not be copied, reproduced or published elswhere without my permission.
Please take attention: I take no responsibility for anything of what this product could do anywhere (forum, other software, server ...).

ThorstenA
01-10-2007, 09:00 PM
Reserved for future posts.

thincom2000
01-10-2007, 09:12 PM
I think it may be better to put an IF { } statement around this, and create a new setting in vBulletin Options to control whether the Announcement is on or off in Forumdisplay. That way you can actually use them if you need to, instead of deleting it entirely from the file.

projectego
01-10-2007, 10:54 PM
Nice work, ThorstonA. Thanks. :)

Just curious though - does implementing this have any negative side-effects?

ThorstenA
01-11-2007, 06:14 AM
I think it may be better to put an IF { } statement around this, and create a new setting in vBulletin Options to control whether the Announcement is on or off in Forumdisplay. That way you can actually use them if you need to, instead of deleting it entirely from the file.
Flagged for future version
Nice work, ThorstonA. Thanks. :)

Just curious though - does implementing this have any negative side-effects?

You do not see announcements on forumdisplay. That's the only effect and it saves one query ;)

JohnBee
02-05-2007, 04:41 PM
I did this MOD, I had 10 queries before I added the mod and I had 10 queries after the edit.
No effect that I can see.

ThorstenA
03-08-2007, 08:59 AM
I did this MOD, I had 10 queries before I added the mod and I had 10 queries after the edit.
No effect that I can see.

It is removing 1 query:

SELECT
announcement.announcementid, startdate, title, announcement.views,
user.username, user.userid, user.usertitle, user.customtitle, user.usergroupid,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
" . (($vbulletin->userinfo['userid']) ? ", NOT ISNULL(announcementread.announcementid) AS readannounce" : "") . "
FROM " . TABLE_PREFIX . "announcement AS announcement
" . (($vbulletin->userinfo['userid']) ? "LEFT JOIN " . TABLE_PREFIX . "announcementread AS announcementread ON (announcementread.announcementid = announcement.announcementid AND announcementread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = announcement.userid)
WHERE startdate <= " . TIMENOW . "
AND enddate >= " . TIMENOW . "
AND " . fetch_forum_clause_sql($foruminfo['forumid'], 'forumid') . "
ORDER BY startdate DESC, announcement.announcementid DESC
" . iif($vbulletin->options['oneannounce'], "LIMIT 1")

Zia
03-16-2007, 04:06 PM
any vb developer has anything to say about it?

ThorstenA
03-22-2007, 08:54 AM
any vb developer has anything to say about it?

vb Team is looking forward to put this query into datastore (or something like that) and just run this query once a day instead of every time forumdisplay is presented to user. Could be integrated into next smaller vbulletin update.

Fenriz
08-04-2009, 11:28 PM
vb Team is looking forward to put this query into datastore (or something like that) and just run this query once a day instead of every time forumdisplay is presented to user. Could be integrated into next smaller vbulletin update.
Has that been done in 3.7.x?