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

Reply
 
Thread Tools
Remove 1 Database Query Per Page Details »»
Remove 1 Database Query Per Page
Version: 1.1, by Trigunflame Trigunflame is offline
Developer Last Online: Nov 2019 Show Printable Version Email this Page

Version: 3.0.7 Rating:
Released: 04-16-2005 Last Update: Never Installs: 18
 
No support by the author.

Remove 1 Database Query Per Page


Intro:
The idea is, lets remove 1 query from each page load, if the person is just refreshing the page. At first this may sound not important or just plain stupid, but on "larger" forums, cutting 1 query is always welcomed I know.

Description:
Basically all this does, is check the current Session Location from the DB against the current WOL path; the Session is already provided by vbulletin, so no extra query there.

All we do, is simply check the Location from the Database against the current WOL, if they don't match then the query is allowed to update the database; if they are the same - it is simply ignored.

Affects:
The only things this will do, is prevent the updating of the "lastactivity", and "location" if a person keeps refreshing the page, IMO that's not really a big deal, vbulletin takes care of deleting and remaking new sessions when they expire anyway. As long as your members are browsing around and such, their lastactivity, location will be updated as per usual.

Updates:
Version 1.1 - Scripts whosonline, misc are allowed to always update.
Version 1.0 - Release

Instructions:
1. [ open includes/sessions.php ]
2. [ go to about line 354, or look for $bypass = intval(SESSION_BYPASS); ]
3. [ replace this block of code ]

PHP Code:
    $DB_site->shutdown_query("
        UPDATE " 
TABLE_PREFIX "session
        SET useragent = '" 
addslashes(USER_AGENT) . "', lastactivity = " TIMENOW $location ", styleid = $styleidiif(VB_AREA !== 'Upgrade'", bypass = $bypass") . "
        ###REPLACE###
        WHERE sessionhash = '" 
addslashes($session['sessionhash']) . "'"
        
'sessionupdate'
); 
4. [ with this block of code]

PHP Code:
    /**
     * Update Location On Page Change
     *
     * @author Trigunflame
     * @version 1.1
     * @copyright Dusty Burns 2005-2006
     */

    // Check Script
    
if ($session['location'] != WOLPATH || THIS_SCRIPT == 'misc' || THIS_SCRIPT == 'online')
    {
        
$DB_site->shutdown_query("
            UPDATE " 
TABLE_PREFIX "session
            SET useragent = '" 
addslashes(USER_AGENT) . "', lastactivity = " TIMENOW $location ", styleid = $styleidiif(VB_AREA !== 'Upgrade'", bypass = $bypass") . "
             ###REPLACE###
             WHERE sessionhash = '" 
addslashes($session['sessionhash']) . "'"
            
'sessionupdate'
        
);
    }

    
/**
     * End Update Locations On Page Change
     */ 
5. [ save file ]

Show Your Support

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

Comments
  #32  
Old 05-18-2005, 02:40 PM
neocorteqz's Avatar
neocorteqz neocorteqz is offline
 
Join Date: May 2002
Location: Barefoot Bay Fl
Posts: 473
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Trigunflame
*wonders how many people have actually used this*

Surprised not that many... oO
I just found this thread.
Reply With Quote
  #33  
Old 05-20-2005, 09:55 PM
GlitterKill GlitterKill is offline
 
Join Date: Jul 2002
Location: Nashville
Posts: 139
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

After installing this hack I am now getting emails like this... 5 so far today:

Database error in vBulletin 3.0.6:

Invalid SQL: INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASviewsFROM threadviews GROUP BY threadid mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASview

mysql error number: 1064

Date: Friday 20th of May 2005 03:56:02 PM
Script: http://forums.pimprig.com/cron.php?&rand=50303
Referer: http://forums.pimprig.com/showthread.php?t=44214
Username: Peng Lord
IP Address: 66.167.218.162

and another:

Database error in vBulletin 3.0.6:

Invalid SQL: INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASviewsFROM threadviews GROUP BY threadid mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASview

mysql error number: 1064

Date: Friday 20th of May 2005 02:56:00 PM
Script: http://forums.pimprig.com/cron.php?&rand=325958
Referer: http://forums.pimprig.com/member.php?u=2606
Username: SpikeShot
IP Address: 68.52.66.139

My dedicated server runs PHP 4.3.11 and MySQL 4.0.24. Any ideas?
Reply With Quote
  #34  
Old 05-21-2005, 12:20 AM
neocorteqz's Avatar
neocorteqz neocorteqz is offline
 
Join Date: May 2002
Location: Barefoot Bay Fl
Posts: 473
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I do believe your problem is here

HTML Code:
INSERTINTOthreadviewsaggregate
Do you have another hack installed which uses the same file?
Reply With Quote
  #35  
Old 05-21-2005, 12:21 AM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GlitterKill
After installing this hack I am now getting emails like this... 5 so far today:

Database error in vBulletin 3.0.6:

Invalid SQL: INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASviewsFROM threadviews GROUP BY threadid mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASview

mysql error number: 1064

Date: Friday 20th of May 2005 03:56:02 PM
Script: http://forums.pimprig.com/cron.php?&rand=50303
Referer: http://forums.pimprig.com/showthread.php?t=44214
Username: Peng Lord
IP Address: 66.167.218.162

and another:

Database error in vBulletin 3.0.6:

Invalid SQL: INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASviewsFROM threadviews GROUP BY threadid mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASview

mysql error number: 1064

Date: Friday 20th of May 2005 02:56:00 PM
Script: http://forums.pimprig.com/cron.php?&rand=325958
Referer: http://forums.pimprig.com/member.php?u=2606
Username: SpikeShot
IP Address: 68.52.66.139

My dedicated server runs PHP 4.3.11 and MySQL 4.0.24. Any ideas?
Don't know what you edited, but it doesn't have anything to do with this hack.. as you are not dealing with anything involving "Inserting" into "Threadviews", you just messed up somewhere.
Reply With Quote
  #36  
Old 05-21-2005, 08:16 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The errors are coming from some Scheduled Task, not from this hack.
Reply With Quote
  #37  
Old 05-21-2005, 03:15 PM
GlitterKill GlitterKill is offline
 
Join Date: Jul 2002
Location: Nashville
Posts: 139
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry this was meant to go into the authors other optimization thread. Sorry.
Reply With Quote
  #38  
Old 05-25-2005, 03:04 PM
David Bott David Bott is offline
 
Join Date: Dec 2001
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed on AVS Forum.
Reply With Quote
  #39  
Old 07-10-2005, 06:22 PM
Thug Thug is offline
 
Join Date: Feb 2004
Location: Sheffield : uk
Posts: 783
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

installed thanx
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 11:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04371 seconds
  • Memory Usage 2,303KB
  • Queries Executed 23 (?)
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_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (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
  • (2)pagenav_pagelink
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)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