prabuj prabha
prabuj prabha

Reputation: 1

SQL - Query Performance

How to find the inefficient queries in mysql database ? I want to do performance tuning on my queries , but i coudn't find where my queries are located ? Please suggest me where can i find mysql queries for my tables .

Thanks

Prabhakaran.R

Upvotes: 0

Views: 85

Answers (3)

Rick James
Rick James

Reputation: 142298

In addition to what the others said, use pt-query-digest (from percona.com) to summarize the slowlog. That will tell you the worst queries.

Performance tuning often involves knowing what indexes to put on tables. My index cookbook is one place to learn how to build an INDEX for a given SELECT.

Upvotes: 0

georgecj11
georgecj11

Reputation: 1637

You can enable the general log and slow query logs.

Enabling general query log will log all the queries and might be heavy if you have many reads/writes. In slow query log, you can mention a threshold and only queries taking time beyond some time will be logged. Post that, you can manually analyze it or you can use tools provided( Percona has great tools)

Upvotes: 2

RadicalPumpkin
RadicalPumpkin

Reputation: 34

Have you analyzed your queries with explain plans? You may be able to find a query that will return the result set you wish that isn't as heavy a load on the query engine. Remember to only select the columns you actually need (try to avoid SELECT *), well planned indexing and to use inner/outer joins in favour of a huge list of WHERE clause filters.

Good luck.

RP

Upvotes: 0

Related Questions