Code Monkey home page Code Monkey logo

sqa's Introduction

sqa

sqa is a Ruby script to analyze MySQL query logs. sqa is capable of examining query logs and determining the most frequently executed SQL statements, the statements that examine the most records, the statements that take the longest amount of time, and more discoveries based on other important metrics.

Usage

Basic Execution

sqa.rb path/to/mysql-slow-query.log

This analyzes the given log file and reports the top 10 most frequently executed SQL statements.

Multiple Log Files

sqa.rb path/to/first-slow-query.log path/to/second-slow-query.log

This analyzes all the given log files and reports the top 10 most frequently executed SQL statements.

Command Line Usage

Usage: sqa.rb [options] file1 file2 ...
    --count NUMBER               Number of items to report.
    --min-calls NUMBER           Minimum number of calls.
    --min-query SECONDS          Minimum average query time in seconds; can be in fraction of seconds.
    --min-lock SECONDS           Minimum average lock time in seconds; can be in fraction of seconds.
    --min-rows-sent NUMBER       Minimum average number of rows returned.
    --min-rows-examined NUMBER   Minimum average number of rows examined.
    --max-row-efficiency PERCENT Maxinum row efficiency as expressed as a percentage.
-a, --sort-ascend TYPE           How the items in the report are sorted. TYPE is one of calls, query, lock, sent, examine, or eff
-d, --sort-descend TYPE          How the items in the report are sorted. TYPE is one of calls, query, lock, sent, examine, or eff
-?, --help                       Display this screen

Examples

Top N Statements

Use the --count NUMBER command line option to control how many statements are returned in the final report. By default, the top 10 statements are reported.

sqa.rb --count 100 mysql-slow-query.log

This reports the top 100 statements.

Filter out Low Frequency Statements

Use the --min-calls NUMBER command line option to filter out low freqency statements from the final report. By default, all calls are included in the analysis.

sqa.rb --min-calls 100 mysql-slow-query.log

This reports only statements which were executed at least 100 times.

Filter out Fast Executing Statements

Use the --min-query SECONDS command line option to filter out statements with a small, average query time. By default, all calls are included in the analysis.

sqa.rb --min-query 2 mysql-slow-query.log

This reports only statements which had an average query time of 2 seconds or more.

Filter out Fast Locking Statements

Use the --min-lock SECONDS command line option to filter out statements with a small, average lock time. By default, all calls are included in the analysis.

sqa.rb --min-lock 1 mysql-slow-query.log

This reports only statements which had an average lock time of 1 second or more.

Filter out Statements with Small Result Sets

Use the --min-rows-sent NUMBER command line option to filter out statement returning a small number of records from the final report. By default, all calls are included in the analysis.

sqa.rb --min-rows-sent 100 mysql-slow-query.log

This reports only statements which return on average at least 100 records.

Filter out Statements that Examine a Small Number of Records

Use the --min-rows-examined NUMBER command line option to filter out statement examining a small number of records from the final report. By default, all calls are included in the analysis.

sqa.rb --min-rows-examined 1000 mysql-slow-query.log

This reports only statements which examine on average at least 1000 records.

sqa's People

Contributors

brentworden avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.