I have a server and it's systems use NodeJS and MySQL.
When I get a lot of users, the MySQL server takes minutes to answer to the querys.
I have tried everything I could find, nothing worked.
Its just a simple query to see if the user is logged or not, and the server takes minutes to answer, when I make a query trough the SSH terminal (mysql -p) it takes less then 1 second, when I make a query trough MySQL it takes less then 1 second too.
The mysql server is not too overloaded, it gets less then 50 querys/s, the VPS its running have spare RAM, CPU, SSD, etc.
The problem happens in every query that the login servers make, to see if the user is logged, to get information about him, to buy something in the shop.
Thanks so much.
If you need to check the query, here is a query to get information about a test user:
http://maq-1.agariohub.net:4040/info/eyJ0b2tlbiI6IjVyeHU4dnFCQklraklYcjljTzV2Mldsc3FhWGZUdHkySzV6ektSdGg1ZllXYnkyZjYxRVZQUm9VdXFRWE1ZZ2QifQ==
The answer is a JSON, in the end of it it shows how much time it took to perform the two querys the server makes
Related
After several minutes of inactivity (no use of the website) MySQL 8 slow right down. An initial query after non-activity can take a minute but thereafter seconds. The same query (like logging in) would take a second or two if there was activity already on the server.
Has anyone encountered this or know how to correct this behavior? The machine itself has a significant amount of resources, its just the first "warm up" call that is slow.
I have a website running in shared hosting environment? I would like to know how many select queries are being run on database?
When I run the following query, I doubt that the result is for whole mysql instance through which the shared hosting is running. Because the difference in result when run with a minute difference is very huge. Definitely not what my website would get.
show global status like "Com_select"
How could I get the number of select queries made in a duration only for my database?
I'm using MySQL workbench to run a query. The query is reasonably big. When I limit the results to say 50 records the results are as expected. But when I remove the limit, the query runs for ~ 5 minutes then prompts me to re-enter my password. After doing so I see the query has not run and has stopped working.
It seems like there is a setting that kicks me off after a certain amount of time but I cannot see it in the drop down menus.
Has anyone experienced this? Any advice?
** Update**
Query ran and Workbench says results returned but they are not and I got the screen shot error pop up here:
It sounds like one of three things are the likely culprit.
MySql Workbench may be timing out.
This may help with #1
Go to Edit -> Preferences -> SQL Editor and set to a higher value this
parameter: DBMS connection read time out (in seconds). For instance:
86400.
Close and reopen MySQL Workbench. Kill your previously query that
probably is running and run the query again.
The mySQL server is timing out
You will need access to the server's timeout configuration
Something network related (but far less likely if your timeout happens consistently at around 5 mins)
There are a number of factors that might need adjusting.
If #2, you will need access to the server's timeout configuration
If #3, well, there are a number of factors that might need adjusting.
I've hit a problem with my MySQL queries and was hoping someone could offer some help/advice.
I'm developing a PHP-based system which combines quite a lot of data in different tabs on one page (tab1 = profile, tab2 = address, tab3 = payments etc.) and as a result, one page can have up to 34/40 MySQL queries pulling from different tables or with different criteria.
The page load became really slow and I asked my web host if they knew what was wrong and they advised it's because of slow MySQL queries (some over 2 seconds). They also said that my MySQL user is only allowed 15 connections at a time.
If my page has 40 queries and only 15 connections are allowed at a time, does this mean they effectively queue and wait for one to complete? If this was the case then I can understand why the page is taking a while to load but i'm not sure of the solution. Is 15 MySQL queries considered a lot or is this quite a tight restriction by my host (HostMonster)?
Also, if there were 15 users accessing the system at the same time, would this 15 connections be split between each of them or is it 15 connections per user logged into the site? I assume they mean per database user but all people who access the system will be using the same database user so it seems impossible to create a system in which several users can access at one?
The whole connections thing has confused me a little.
Thanks in advance for any help!
Have one connection per page. Put the queries into sequence
Optimize those queries - see explain and use indexes
Perhaps combine queries to reduce the through put.
BTW 10+ queries per page is excessive IMHO.
If having max connect error problem then use this command from command line
mysqladmin flush-hosts -uuser -p'password'
this will flush hosts that MySQL has recorded and will build the list again. In the newer version of MYSQL 5.6 you get more information on this but not on previous version.
You can set the following
max_connect_errors 10000
to avoid the message to appear again.
15 queries or connection is not a problem at all, in busy databases we have seen thousand connections and tens of thousands of queries per second.
I have an SQL query that takes 7 seconds to run on one computer, but on another computer (identical hardware, database has been copied over with mysqldump and so is the same), that same query runs for over 2000 seconds.
How do I find out why this is? All the advice I can find online about debugging slow mysql seems to boil down to 'find the slow queries'. That doesn't help me here. Show processlist doesn't show any other queries running, so why is it taking hundreds of times longer to execute this one on one computer than another?
What I understand is that your SQL Server is same in BOTH conditions. What you are saying is that when query x is executed from client1 it takes few seconds; while from other client client2 it is taking more than 2000 seconds.
I feel problem is network between client2 and your database server. Try to to ping between these two servers. It should give you some hint. This theory is also supported by the fact that you mentioned that server is NOT showing query getting executed.
If in both conditions SQL Servers are different; while indexes etc. are identical ; then problem is that ANALYZE has not been executed on client2 since long time.