I think I have a basic understanding of this, but am hoping that someone can give me more details as I am interested in learning more about database performance.
Lets say I have a very large database, with many millions of entries, the database supports many connections. Doing simple queries on the database will be slow as there's so much data. I'm trying to understand exactly when a query on a given connection starts to have a direct effect on the performance of queries running on other connections.
If one connection locks some elements, I understand that that will hold up queries running the other connections that need those elements . For example doing:
SELECT FOR UPDATE
will lock what you are selecting.
What happens when you do something simple like:
SELECT COUNT(*) FROM myTable
lets say we have a table with a billion rows so running the count is going to take some time (running on innodb). Will it affect queries running on other connections?
What if you select a large amount of data using SELECT and JOIN, like:
SELECT * FROM myTable1 JOIN myTable2 ON myTable1.id = myTable2.id;
does having a join lock anything for other queries?
I'm finding it hard to know which queries will have a direct effect on the performance of queries running on other connections.
Thanks
It is safe to log slow queries with execution time bigger than a second without worry about performance impact in case of CPU-bound workload. The performance impact is negligibly small in IO-bound workload even if all queries are logged.
The slow query log consists of SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined. The slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization.
Slow running queries in SQL server can be caused by bad physical structure of a database or may be due to the latency in network communication etc. Another problem with long running queries is the issue in configuration of SQL Server.
Simultaneous MySQL connection limits Each database user is limited to 38 simultaneous MySQL connections. This limitation helps to prevent overloading the MySQL server to the detriment of other sites hosted on the server.
There are different angles:
About this second point, the problem is mainly divided in 3 areas:
About disk reads: the more data (in bytes) you will retrieve, the more the harddrive is going to be busy and slowdown any other activity using it. Reduce the size of selected rows to avoid disk overhead.
About memory usage: mysql manages an internal buffer, that can get stuck in some situations. I don't know enough about it to give you a proper answer, but I know this is definetly something you should keep an eye on.
About cpu usage: basically the cpu will get busy when it
So, now when to know when there's a collateral effect? By profiling your hardware... How to profile?
SHOW INNODB STATUS
or SHOW PROFILE
to get useful informations about main mysql harddrive, cpu and memory watches.perfmon.exe
and watch for PRIVATE BYTES
and VIRTUAL BYTES
of the mysql process. I say relative, because afterall if a query is time consuming on your computer, it might not be on the NASA system... Hope it helps, regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With