Hello, at time when opening the pages on my site you get the "max connections by user" php error in the queries.. is there a way to forward to some error page if such error occurs? Thanks in advance
Something like: mysql_connect(PARAMTERS) or $error=mysql_error(); Just match $error with the error you get when you have max connections and just header redirect. Peace,
It sounds as if your mysql server is running out of connections. Make sure you arent using pconnect and take a look at your my.conf file. You might want to increase max_connections Hope this helps
Thanks for the reply! my max connections where set to 0 aka unlimited ... but that was not doing the trick so i had it changed to some very large number. I will check on the pconnect. It is probably my poor coding job thought Thanks everyone for help
Code yourself close for mysql, and also have the mysql config set to like 15 or 30 sec max connect to keep runaway scripts from staying open.
aren't all the connections closed automatically after the whole page is parsed in the newer php verisons? thanks for the suggestion though
Thats right, however not closing it bad coding habits, and it not a 100% that they close. For example you can start a page and kill the page and yet the SQL server will continue to run the query even after the script has closed down. I run a server that has more than 1 million inserts running per 1/2 min all day long.. its not that uncommon. You can sometimes see them as null sleeping threads in SQL.
Thanks again, I do use <? mysql_close($link); ?> PHP: so that should not be the issue, i contacted dedicated host support and the max_connections setting and it was only set to 20.... so now I changed it to 100 hopefully that will do the trick p.s. also, could you please send me a pm with your cost to look at one or two of the pages of my script and maybe help optimize the script, since I coded it myself with no previous knowledge of php/mysql
1 million inserts every half a minute for a whole day? Is that even possible on 1 mysql server? If so i am very interested to know your my.cnf settings and your server stats.
fgs, sorry Im not for hire... tonybogs... my.cnf is really just a small part of your focus. We have max query times for queries are like 30s, and something like max threads of 200. On one box we have 9gb of ram and 80% of that is for mysql. You have to focus on your table designs, and queries. For example most people when they want to get a result count they will do something like SELECT count(*) as TotalResults FROM sometable WHERE something = ..... However this is the wrong way to go about it IMO. As mysql has to rip down the entire table to count all the rows, and like most script its then followed by yet another query to get the results. Its slow... so the mart way to get a row count is to do SQL_CALC_FOUND_ROWS.. eg SELECT SQL_CALC_FOUND_ROWS somefield, anotherfield FROM sometable WHERE something = ...... then after that has been run you run one more query to get the SQL_CALC with "SELECT FOUND_ROWS() AS TotalCount". Now your not raping the database to get a count, your just running a query for the results you want and then calculating the remaining rows. Other things are processing your raw data into another table, then loading the keys into memory. There are a million ways to go about it, its up to what you need.. However its all about your table designs and queries. Best, Levi ps.. sorry.. server stats... dual zion 3.6Ghz or something, 9gb ram.. a bunch of drive.. LOL memory is fuzzy, we just order anyother box if the load starts getting high(7-10), as we normally ride <2, but max at 5. ;p When you do that many inserts the insert table can not have anything but inserts running on it. You can also do like InnoDB depending on what the table is for.