GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MYSQL-GENOCIDE (1)

.ds Aq ’

NAME

mysql-genocide - Parallel operation on MySQL processlist

CONTENTS

SYNOPSIS

mysql-genocide [OPTIONS] [FILTER]



 Options:
   -h, --help               Show help.

   Connection:
   -h, --host=name          Connect to host.
   -P, --port=#             Port number to use for connection.
   -D, --database=name      Database to use.
   -u, --user=name          User for login if not current user.
   -p, --password=name      Password to use when connecting to server.

   Filters:
   -e, --exclude            Exclude queries by different criteria
   -s, --selects-only       Exclude everything but selects
   -t, --min-time=#         Exclude queries with exec time lower than #
   -T, --timeout            Exclude queries with exec time lower than query time hint
   -l, --limit=#            Only take first # lines
   -g, --placeholder        Replace values in queries by placeholders
   -d, --distinct           Only keep the first occurence of the same query
   --sort                   Sort result

   Actions:
   -L, --list               Output list of queries
   -K, --kill               Kill every matched threads
   -S, --stats              Show some stats about processlist

   -i, --interval[=#]       Repeat the command at regular interval



OPTIONS

<B>--helpB> Print a brief help message and exits.
<B>--hostB>, <B>--portB>, <B>--databaseB>, <B>--userB>, <B>--passwordB> See <B>mysqlB> cli help for more information on those parameters.
<B>--exclude=[!]nameB> Exclude from the running thread list queries matching the argument. This parameter can be repeated several times to exclude different kinds of queries. If you prefix the argument with an exclamation mark (!), all thread not matching this argument will be excluded. Allowed parameters are:

<B>select, insert, replace, update, delete, create, drop, alterB>

Exclude SQL query which command is of the same name.

<B>writeB>

Exclude every SQL query doing write operation (insert, replace, update, delete).

<B>otherB>

Exclude SQL query which are none of the above type.

<B>sleepB>

Exclude all sleeping threads

<B>systemB>

Exclude thread ran by the system (often used for replication threads)

<B>user=B><user>

Exclude threads ran by given mysql username.

<B>db=B><db>

Exclude threads using given database.

<B>state=B><state>

Exclude threads in given state.

See <http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html> for the list of possible states

<B>command=B><command>

Exclude threads using given command.

See <http://dev.mysql.com/doc/refman/5.0/en/thread-commands.html> for the list of possible commands.

<B>--selects-onlyB> This is equivalent to: --exclude=write --exclude=other --exclude=sleep --exclude=system.
<B>--min-time=#B> Exclude queries with execution time lower than given parameter.
<B>--timeoutB> Keep only queries with a timeout provided and with an execution time which exceeded this timeout. The timeout can be provided with the query in a comment like this:



  SELECT /* timeout:40 */ * FROM table;



Timeout is expressed in second.

<B>--limit=#B> Take first # threads and excludes others.
<B>--placeholderB> Will try to make queries more generic by replacing all values by either i for numbers or s for strings.
<B>--distinctB> Keep only the first query from group of identical queries and exlude others.

Note: If you use this option with <B>--placeholderB>, queries that would differ only by values used will become identical. This is useful to distinct big type of queries.

<B>--sort[=name]B> Sort matched queries by parameter given as argument.

Allowed parameters are as follow:

<B>concurrencyB> or <B>cB>

Sort queries by most repeated ones.

<B>timeB> or <B>tB>

Sort queries by longer execution time.

<B>--list[=template]B> Output the result to the terminal.

The default output format can be changed by supplying a template with desired field.

Available fields are: <B>IdB>, <B>UserB>, <B>CommandB>, <B>StateB>, <B>DbB>, <B>HostB>, <B>TimeB>, <B>InfoB>, <B>GroupB>, <B>ConcurrencyB>, <B>QTypeB>, <B>TimeoutB>

Default template is: <Id> <User> <Db> <Time> <Info>

<B>--killB> Kill every threads that match the given filters.
<B>--statsB> Show statistics about queries matched by filters.
<B>--interval[=#]B> Repeat the command at regular interval. Interval in second can be specified as argument. If not specified, default interval is 5 seconds.

DESCRIPTION

mysql-genocide helps you play with big MySQL processlists. It can filter it using different criterias like execution time, query type, user or regexp matching of the SQL query etc. Actions can then be peformed on the result like killing, sorting or generating statistics.

EXAMPLES

Kill all selects with execution time geater than 60 seconds:



    mysql-genocide --selects-only --min-time 60 --kill



Same as before but limited on queries matching a pattern:



    mysql-genocide -s -t 60 -K FROM user 



Kill all queries timed out:



    mysql-genocide --timeout --kill



Replace queries values by placeholders and group identical queries together, sort them by most concurrent and keep only the 10 most concurent ones:



    mysql-genocide --placeholder --group --sort concurrency --limit 10 --list



SQL EXTENDED INFO

You can add some information in your SQL queries to help mysql-genocide to do some decisions. To pass this kind of information, you can use SQL comments like this:



  /* VARIABLE[:VALUE] */ SELECT * FROM...



NOTE: in certain versions of mysql CLI client strip comments before to send them to the server.

AVAILABLE EXTENDED INFO
<B>TIMEOUT:SECONDSB> This option hint mysql-genocide on the maximum execution time the query should take. The option <B>--timeoutB> will keep only queries with an execution time which exceeded this value.

The timeout can be provided with the query in a comment like this:



  /* timeout:40 */ SELECT * FROM table;



Timeout is expressed in second.

<B>DO_NOT_KILLB> If this option is present in query, the query won’t be killed when <B>--killB> option is used, even if it match the filters. If you combine <B>--listB> and <B>--killB> on the same command, such queries will appear in the listed queries but won’t be killed.

Example query:



  /* DO_NOT_KILL */ SELECT * FROM important_data;



SCRIPT CATEGORIES

Unix/System_administration

PREREQUISITES

This script requires the DBD::mysql, Getopt::Long and Pod::Usage modules.

OSNAMES

any

AUTHOR

Olivier Poitrey <rs@dailymotion.com>
Search for    or go to Top of page |  Section 1 |  Main Index


perl v5.20.3 MYSQL-GENOCIDE (1) 2008-06-14

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.