Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

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

Version: 3.5.3 Rating:
Released: 02-10-2006 Last Update: Never Installs: 31
Code Changes  
No support by the author.

[CENTER]Remove 1 Database Query Per Page
Reduce your forums query usage !

Summary: (Quoted From Original Hack for vb3)

Removes 1 Query Per Page.

Instructions:

1. Open includes/class_core.php
2. Go to about line 2538 and look for
PHP Code:
$this->set('location'WOLPATH); 
3. Above that, paste the following.
PHP Code:
$this->set('old_location'$session['location']); 
4. Go to about line 2818 and look for the following:
PHP Code:
            // registered user
            
if (!SESSION_BYPASS)
            {
                if (
TIMENOW $this->userinfo['lastactivity'] > $this->registry->options['cookietimeout'])
                {
                    
// see if session has 'expired' and if new post indicators need resetting
                    
$this->registry->db->shutdown_query("
                        UPDATE " 
TABLE_PREFIX "user
                        SET
                            lastvisit = lastactivity,
                            lastactivity = " 
TIMENOW "
                        WHERE userid = " 
$this->userinfo['userid'] . "
                    "
'lastvisit');

                    
$this->userinfo['lastvisit'] = $this->userinfo['lastactivity'];
                }
                else
                {
                        
$this->registry->db->shutdown_query("
                            UPDATE " 
TABLE_PREFIX "user
                            SET lastactivity = " 
TIMENOW "
                            WHERE userid = " 
$this->userinfo['userid'] . "
                            "
'lastvisit');
                }
            } 
5. Replace that with the following:
PHP Code:
            // registered user
            
if (!SESSION_BYPASS)
            {
                if (
TIMENOW $this->userinfo['lastactivity'] > $this->registry->options['cookietimeout'])
                {
                    
// see if session has 'expired' and if new post indicators need resetting
                    
$this->registry->db->shutdown_query("
                        UPDATE " 
TABLE_PREFIX "user
                        SET
                            lastvisit = lastactivity,
                            lastactivity = " 
TIMENOW "
                        WHERE userid = " 
$this->userinfo['userid'] . "
                    "
'lastvisit');

                    
$this->userinfo['lastvisit'] = $this->userinfo['lastactivity'];
                }
                elseif (
$this->vars['old_location'] != WOLPATH || THIS_SCRIPT == 'misc' || THIS_SCRIPT == 'online')
                {
                    
$this->registry->db->shutdown_query("
                        UPDATE " 
TABLE_PREFIX "user
                        SET lastactivity = " 
TIMENOW "
                        WHERE userid = " 
$this->userinfo['userid'] . "
                        "
'lastvisit');
                }
            } 

Show Your Support

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

Comments
  #12  
Old 02-11-2006, 10:32 PM
Kihon Kata Kihon Kata is offline
 
Join Date: Nov 2003
Posts: 763
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Trigunflame
Because if you would look at the query:

$this->registry->db->shutdown_query()

It is a shutdown query that is run as the script is ending, and is not shown in any query counters. Nevertheless it is still sending that query to your forums mysql database which affects the system.

I didnt say this would necessarily make your forum "Faster", I just said it would reduce a query, lol.

Go read my thread in vb3 if you dont believe me...
Oh, all I said is that when the stats lists, it's the same number of queries listed, that's all. Nothing about speed or "Faster".

Anyhow, thanks for this
Reply With Quote
  #13  
Old 02-12-2006, 09:19 AM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much. I always wanted to reduce the query usage on my forums but guess what, this helps a lot!
Reply With Quote
  #14  
Old 02-12-2006, 09:48 AM
NuclioN's Avatar
NuclioN NuclioN is offline
 
Join Date: Aug 2002
Posts: 955
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Trigunflame the code to replace at the very bottom of the last replacement says you have to overwrite. That section in the original has this:

Code:
$this->registry->db->shutdown_query("
						UPDATE " . TABLE_PREFIX . "user
						SET lastactivity = " . TIMENOW . "
						WHERE userid = " . $this->userinfo['userid'] . "
					", 'lastvisit');
				}
			}
		}
	}
}
-----------------------

According to the manual i have to overwrite the first two } is that correct?
Reply With Quote
  #15  
Old 02-12-2006, 09:59 AM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by NuclioN
Trigunflame the code to replace at the very bottom of the last replacement says you have to overwrite. That section in the original has this:

Code:
$this->registry->db->shutdown_query("
						UPDATE " . TABLE_PREFIX . "user
						SET lastactivity = " . TIMENOW . "
						WHERE userid = " . $this->userinfo['userid'] . "
					", 'lastvisit');
				}
			}
		}
	}
}
-----------------------

According to the manual i have to overwrite the first two } is that correct?
Just replace the php code in the first php example, with the php code in the 2nd example.
Reply With Quote
  #16  
Old 02-12-2006, 10:14 AM
NuclioN's Avatar
NuclioN NuclioN is offline
 
Join Date: Aug 2002
Posts: 955
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tnx Every reduce of query is usefull
Reply With Quote
  #17  
Old 02-12-2006, 03:22 PM
o0Hubba0o's Avatar
o0Hubba0o o0Hubba0o is offline
 
Join Date: Mar 2005
Location: Minnesota
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
3. Above that, paste the below
So does it go above? Or does it go below?

Wait, I think I understand now that I look at what I typed, your saying to paste what's below above this "$this->set('location', WOLPATH); " right? Maybe change it to say: "3. Above that, paste the following:". Otherwise more people might get confused if they're looking at this right after getting up in the morning like me hehe.
Reply With Quote
  #18  
Old 02-12-2006, 08:37 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by o0Hubba0o
So does it go above? Or does it go below?

Wait, I think I understand now that I look at what I typed, your saying to paste what's below above this "$this->set('location', WOLPATH); " right? Maybe change it to say: "3. Above that, paste the following:". Otherwise more people might get confused if they're looking at this right after getting up in the morning like me hehe.
It doesnt matter if you paste it below it or above it, just a 1 liner.
Reply With Quote
  #19  
Old 02-18-2006, 01:53 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*bump*
Reply With Quote
  #20  
Old 02-18-2006, 03:24 PM
dutchbb dutchbb is offline
 
Join Date: Nov 2003
Posts: 899
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm still not sure what changes when I remove the query. And if it doesn't change speed I rather keep the extra query
Reply With Quote
  #21  
Old 02-20-2006, 07:12 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Triple_T
I'm still not sure what changes when I remove the query. And if it doesn't change speed I rather keep the extra query
If you dont care, dont worry about it :tired:
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 08:24 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.05147 seconds
  • Memory Usage 2,344KB
  • 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
  • (2)bbcode_code
  • (4)bbcode_php
  • (5)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
  • (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