Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles

Reply
 
Thread Tools
Work Around: Error SQL server exceeded max questions
Zachariah's Avatar
Zachariah
Join Date: Feb 2002
Posts: 2,125

AS Electronics Experance in PHP, HTML, JavaScript, DHTML, Flash, XML, MySQL, Photoshop, more. Electronics I, II, III, Microprocessors, AC and DC Electronics, Boolean Algebra, Trig / Math Analysis, Chemistry / AP Physics

Canoga Park, CA
Show Printable Version Email this Page Subscription
Zachariah Zachariah is offline 02-09-2009, 10:00 PM

vBulletin: 3.0x / 3.5x / 3.6x / 3.7x / 3.8x

Quote:
"Error: SQL server exceeded 50,000 max questions"
- All mySQL is stopped for like 5 min then all is ok.
- The server it self auto temp bans the mysql account in use.

I am sure others may have ran into this issue. I have ran into many webhosts that because of "server loads" have a cap on max questions mySQL server can be given in a time frame. (1 hour in my case) This becomes a huge problem when doing maintenance of "Update Counters" in the AdminCP.

One workaround is to create multiple mysql users in your hosting account. In config.php you randomly pick one of these users to connect to the database. This will spread the questions between users and since the limit is per user. This is not a perfect solution for if an account maxes out the script will stop, but you can usually overcome the problem.

I set up 7 accounts in mySQL up on 1 database all using the same password.
I ran 236,968 queries without a hiccup.

Edit:
includes/config.php

Find:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ****** 
//    This is the username and password you use to access MySQL. 
//    These must be obtained through your webhost. 

$config['MasterServer']['username'] = '';
$config['MasterServer']['password'] = ''
Replace with:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ******
//    This is the username and password you use to access MySQL.
//    These must be obtained through your webhost.
$dblogins = array();

$dblogins['1']['user'] = 'user1';
$dblogins['2']['user'] = 'user2';
$dblogins['3']['user'] = 'user3';
$dblogins['4']['user'] = 'user4';
$dblogins['5']['user'] = 'user5';
$dblogins['6']['user'] = 'user6';
$dblogins['7']['user'] = 'user7';

srand((float) microtime() * 10000000);
$dbloginid array_rand($dblogins);
while (
$dblogins[$dbloginid]['user'] == '')
{
    
$dbloginid array_rand($dblogins);
}
$config['MasterServer']['username'] = $dblogins[$dbloginid]['user'];

unset(
$dblogins$dbloginid);

$config['MasterServer']['password'] = 'password'
1) Make sure and replace user1, user2, user3, user4, user5, user6, user7 with the correct user names made for the database.

2) Also replace password with the correct password.
Reply With Quote
  #12  
Old 05-15-2010, 10:41 PM
Zachariah's Avatar
Zachariah Zachariah is offline
 
Join Date: Feb 2002
Location: Canoga Park, CA
Posts: 2,125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by thinkfast View Post
is this work for vbulletin 4?
Yes this should work the same.
Reply With Quote
  #13  
Old 06-01-2010, 08:11 AM
Alecsmith Alecsmith is offline
 
Join Date: Sep 2009
Location: Still On Earth
Posts: 217
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

first of though this will make forum loading fast but after i adding more Mysql users but it made forum loading very slow
Reply With Quote
  #14  
Old 12-19-2010, 12:46 AM
Poker Face Poker Face is offline
 
Join Date: Sep 2010
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachariah View Post
Replace with:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ******
//    This is the username and password you use to access MySQL.
//    These must be obtained through your webhost.
$dblogins = array();

$dblogins['1']['user'] = 'user1';
$dblogins['2']['user'] = 'user2';
$dblogins['3']['user'] = 'user3';
$dblogins['4']['user'] = 'user4';
$dblogins['5']['user'] = 'user5';
$dblogins['6']['user'] = 'user6';
$dblogins['7']['user'] = 'user7';

srand((float) microtime() * 10000000);
$dbloginid array_rand($dblogins);
while (
$dblogins[$dbloginid]['user'] == '')
{
    
$dbloginid array_rand($dblogins);
}
$config['MasterServer']['username'] = $dblogins[$dbloginid]['user'];

unset(
$dblogins$dbloginid);

$config['MasterServer']['password'] = 'password'
1) Make sure and replace user1, user2, user3, user4, user5, user6, user7 with the correct user names made for the database.

2) Also replace password with the correct password.
This isn't working for some reason... where does the database name 'username' get inserted or replaced, as in the original instructions?

My Database: $config['Database']['dbtype'] = 'mysqli';
Reply With Quote
  #15  
Old 02-21-2011, 06:02 PM
combs combs is offline
 
Join Date: Aug 2007
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is genius. I didn't want to change servers and Hostgator can be a real pain in the ass. I did this and the forum was INSTANTLY faster and the hundreds of errors in my email have stopped(for now..let it continue). Thanks a ton man!
Reply With Quote
  #16  
Old 02-22-2011, 12:11 AM
Videx's Avatar
Videx Videx is offline
 
Join Date: Feb 2007
Posts: 3,085
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by combs View Post
This is genius.
Only until they catch you. They've limited you to 25 connections per account, not per user (which would basically be unlimited connections).
Reply With Quote
  #17  
Old 02-22-2011, 12:31 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some webhosts will ban you for this, find a REAL webhost.
Reply With Quote
  #18  
Old 03-07-2011, 07:26 PM
thincom2000 thincom2000 is offline
 
Join Date: May 2006
Location: Bronx, NY
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there any other benefit from spreading the connections over multiple accounts (slight performance gain, maybe)? I just moved to a dedicated server, and am wondering if I even need this any more.
Reply With Quote
  #19  
Old 03-09-2011, 08:32 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope.
Reply With Quote
  #20  
Old 05-24-2011, 10:07 AM
SVTCobraLTD SVTCobraLTD is offline
 
Join Date: Jul 2007
Location: PA
Posts: 841
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am going to try this, hopefully it eliminates my errors:

Quote:
mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections
/home/xxxxxxx/forums/includes/class_core.php on line 311
Reply With Quote
  #21  
Old 05-25-2011, 01:11 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

SVT, it wont in your case, your mysql server has reached the GLOBAL limit, not your user limit.
Reply With Quote
Reply

Thread Tools

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 10:06 AM.


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.04546 seconds
  • Memory Usage 2,321KB
  • 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
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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