fawad
fawad

Reputation: 1353

Which SQL Query takes more time? (MYSQL)

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

Answers (4)

Kibbee
Kibbee

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

Ted Hopp
Ted Hopp

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

Paul Sonier
Paul Sonier

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

Cyril N.
Cyril N.

Reputation: 39859

You can use the Mysql Slow Query Log.

Upvotes: 4

Related Questions