#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    110
    Rep Power
    24

    How to return max_questions?


    My host currently caps my queries (max_questions) to 75,000; however, anyone who has done database work knows that's not enough.

    Is there a way to return a user's current 'question' count? If I can get this I can write a script to change users - just a thought.
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,204
    Rep Power
    4279
    Originally Posted by mbreezy
    Is there a way to return a user's current 'question' count?
    yes, there is

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    110
    Rep Power
    24
    Could you please help me with it, then? I'm at a standstill. I seen code how to change it, but since I dont have root access to MySQL I can't change it. I just want to see how many queries I've done in the last hour or so.
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,204
    Rep Power
    4279
    oh, wait, now i understand what you're asking

    sorry, i have no idea
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    110
    Rep Power
    24
    Originally Posted by r937
    oh, wait, now i understand what you're asking

    sorry, i have no idea
    Oh okay.

    I figure if there's a numerical limit on something surely I can return the current value of whatever is limited thus preventing myself of attaining the limit.

    So if the limit is 75,000 queries an hour, before each query I would return the current query count and based on that I can switch users.
  10. #6
  11. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    539
    Try
    Code:
    show session status where variable_name = 'Questions';
    should give you the desired info.


    Or the IMHO cleaner use of system views
    Code:
    SELECT 
     s.* 
    FROM 
     information_schema.SESSION_STATUS S
    where
     s.variable_name = 'QUESTIONS';
  12. #7
  13. garish grotesque gargoyle
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2006
    Location
    gracing gargantuan gothic gateways
    Posts
    1,337
    Rep Power
    1037
    it's less refined than your potential solution, however you could probably just write your code to do the different user connect whenever a query failed (with the appropriate error)... you may not be able to see ahead of time whether you're at the limit, but if you're writing branching code for a reconnect before every query anyway I don't see how this would be much different...
    HTH - derelict

    "Human history becomes more and more a race between education and catastrophe." (H.G. Wells)
    "Giving me a new idea is like handing a cretin a loaded gun, but I do thank you anyhow, bang, bang." (Philip K. D!ck)
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    110
    Rep Power
    24
    Originally Posted by pabloj
    Try
    Code:
    show session status where variable_name = 'Questions';
    should give you the desired info.


    Or the IMHO cleaner use of system views
    Code:
    SELECT 
     s.* 
    FROM 
     information_schema.SESSION_STATUS S
    where
     s.variable_name = 'QUESTIONS';
    I could not get this to work. I'm getting in invalid argument - however I really want to use this!
    Originally Posted by derelict
    it's less refined than your potential solution, however you could probably just write your code to do the different user connect whenever a query failed (with the appropriate error)... you may not be able to see ahead of time whether you're at the limit, but if you're writing branching code for a reconnect before every query anyway I don't see how this would be much different...
    HTH - derelict
    Very nice idea... So something like this is what you're talking about?
    PHP Code:
    $dbusers = array('user1''user2''user3''user4');
    $yy 0;
    while(!
    mysql_connect ($dblocation$dbusers[$yy], $dbpass))
    {
        
    $yy++;

    Is that a sloppy way to code that?

    I appreciate all of your help!

    One other question...

    Say I'm in the middle of a connection with many, many queries. Is there a way I can catch the error and reconnect with another user and continue one with what was being executed?

    For example, the script connects to the DB and begins to execute 100 queries. At query 50 I get to my max_questions and the server kicks back the error. Can I have it reconnect with a different user and continue on?

IMN logo majestic logo threadwatch logo seochat tools logo