Reputation: 1353
How to check which sql query is taking more time? (MYSQL) Im using a dedicated Linux server and the website is consuming 1 GB of RAM, the company says its because of SQL queries (MYSQL). Can anybody tell me how to check which sql queries is taking more time and utilizing more resources?
Upvotes: 5
Views: 1950
Reputation: 66112
MySQL memory usage, while it does have to do with queries being run also has to do with the configuration of MySQL itself, and the amount of data being stored in MySQL. You can limit the amount or memory used by MySQL by tweaking the settings in my.cnf However, giving less memory to MySQL is a sure way to slow it down. This can be offset someuhat by using proper indexes for the queries you are running. For a good overview of memory options, see this article
Upvotes: 0
Reputation: 234795
You can use EXPLAIN to see which of your queries can be improved. The MySQL logs might also give you a hint about what's using up so much memory.
Upvotes: 0
Reputation: 39480
Mysql provides the EXPLAIN keyword to display the execution plan of queries; simply put "EXPLAIN" in front of your query, and Mysql will display the execution plan of that query.
http://dev.mysql.com/doc/refman/5.0/en/explain.html
Upvotes: 2