4) Information schema & performanc schema.pdf

Embed Size (px)

Citation preview

  • MySQL INFORMATION SCHEMA

    & PERFORMANCE SCHEMA

  • Agenda

    MySQL Information_schema

    Tables in Information_schema

    MySQL Performance schema

  • About Us

    Karthik.P.R, Senior MySQL DBA,

    Bharath Kumar.P, MySQL DBA

    Blog : remotemysqldba.blogspot.in

  • Remotemysqldba.blogspot.in

    MySQL Information Schema

    Information_schema is a virtual MySQL database that stores metadata

    information of all the MySQL databases.

    From MySQL 5, when we execute

    the show databases command

    information_schema will be

    listed in the database list.

    The important thing to remember

    about the information_schema database

    is that you can query it, but you cannot

    change its structure or modify its data.

    It can not be dumped using mysqldump.

  • Remotemysqldba.blogspot.in

    MySQL Information Schema

    Using the information_schema views, you can execute the standard select SQL command to get the metadata information.

    Contains following types of information:

    Table Information

    Partioning

    Privileges

    Character Set Support

    Constraint and Indexes

    Server Settings and Status

    Routines and Related Infromation

    InnoDB

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    CHARACTER_SETS

    COLLATIONS

    COLLATION_CHARACTER_SET_APPLICABILITY

    COLUMNS

    COLUMN_PRIVILEGES

    ENGINES

    EVENTS

    FILES

    GLOBAL_STATUS

    GLOBAL_VARIABLES

    KEY_COLUMN_USAGE

    OPTIMIZER_TRACE

    PARAMETERS

    PARTITIONS

    PLUGINS

    PROCESSLIST

    PROFILING

    REFERENTIAL_CONSTRAINTS

    ROUTINES

    SCHEMATA

    SCHEMA_PRIVILEGES

    SESSION_STATUS

    SESSION_VARIABLES

    STATISTICS

    TABLES

    TABLESPACES

    TABLE_CONSTRAINTS

    TABLE_PRIVILEGES

    TRIGGERS

    USER_PRIVILEGES

    VIEWS

    INNODB_CMP_RESET

    INNODB_TRX

    INNODB_CMPMEM_RESET

    INNODB_LOCK_WAITS

    INNODB_CMPMEM

    INNODB_CMP

    INNODB_LOCKS

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    CHARACTER_SETS :

    This table provides the information about the available character sets.

    Each language functions need different character sets.

    COLLATIONS:

    The collation table provides the information about the collations for

    each character set.

    COLLATION_CHARACTER_SET_APPLICABILITY:

    This table indicates what character set is applicable for what collation.

    COLUMNS :

    The columns table provides information about columns in tables.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    COLUMN_PRIVILEGES :

    This table provides information about column privileges. This

    information comes from the mysql.columns_priv table.

    ENGINES :

    This table provides the output of show engines; statements.

    EVENTS :

    It shows all the information about the event scheduler.

    GLOBAL_STATUS & GLOBAL_VARIABLES:

    They give the info about the server variables and status. show global

    variables and show global status commands.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    KEY_COLUMN_USAGE :

    It shows which key columns have constraints. The column that has

    foreign key references. It also shows the relation between tables.

    PARAMETERS :

    It gives information about stored procedure and function parameters. It

    gets data from mysql.proc table.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    PARTITIONS :

    It gives information about the partitioned tables and their sub partitions.

    PLUGINS :

    It show what are the plug-ins installed and their description. It is

    equivalent to show plugins

    PROCESSLIST:

    It gives the list of all the threads running inside the mysql server . It is equivalent to show full processlist.

    It helps to get the queries running beyond certain duration or queries running by a certain user.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    PROFILING :

    This table provides statement profiling information. If profiling is enabled . It is similar to show profile.

    Profiling helps us to identify the bottle neck in a query.

    REFERENTIAL_CONSTRAINTS :

    This table provides information about foreign keys.

    ROUTINES :

    This table provides information about stored routines in a detailed

    manner.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    SCHEMATA :

    It show what are the databases present in the server.

    SCHEMA_PRIVILEGES :

    This table provides information about schema (database) privileges. It

    takes them from mysql.db tables.

    STATISTICS :

    This table provides information about table indexes.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    TABLES :

    This table provides information about all tables in databases. It has

    more and more data about the tables.

    1) data size

    2) index size

    3) number of rows

    4) average row length ,etc

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    TABLESPACES:

    This table provides information about active tablespaces.

    TABLE_CONSTRAINTS :

    This table describes which tables have constraints. The information is

    about the same as what you get from the show index from

    table_name.

  • Remotemysqldba.blogspot.in

    Tables In Information_Schema

    TABLE_PRIVILEGES :

    This table provides information about table privileges. This information

    comes from the mysql.tables_priv table.

    TRIGGERS :

    This table provides information about triggers.

    USER_PRIVILEGES :

    The table provides information about global privileges. This

    information comes from the mysql.user table.

    VIEWS :

    The table provides information about views in databases.

  • Remotemysqldba.blogspot.in

    Information_Schema Examples

    Query to display tables with more than 1000 rows.

  • Remotemysqldba.blogspot.in

    MySQL Information Schema

    Query to list top 5 largest tables in the database.

  • Remotemysqldba.blogspot.in

    MySQL Performance Schema

    MySQL Performance Schema is a feature for monitoring MySQL Server

    execution at a low level.

    The Performance Schema is available as of MySQL 5.5.3 .

    It provides a way to inspect internal execution of the server at runtime.

    It monitors server as events.

    An event is anything the server does that takes time and has been

    instrumented so that timing information can be collected

    The Performance Schema storage engine collects event data using

    instrumentation points in server source code.

    Collected events are stored in tables in the performance_schema database.

  • Remotemysqldba.blogspot.in

    MySQL Performance Schema

    It provide access to useful information about server execution while having

    minimal impact on server performance.

    Tables in the performance_schema database are views or temporary tables

    that use no persistent on-disk storage.

    Monitoring is available on all platforms supported by MySQL.

    No separate threads associated with the Performance Schema, unlike other

    features such as replication or the Event Scheduler.

  • Remotemysqldba.blogspot.in

    MySQL Performance Schema

    Activating the Performance Schema causes no changes in server

    behavior.

    No memory allocation is done beyond that which occurs during server

    startup

    Server monitoring occurs continuously and unobtrusively with very

    little overhead. Activating the Performance Schema does not make the

    server unusable.

    Execution of server code proceeds normally even if the Performance

    Schema fails internally.

  • Remotemysqldba.blogspot.in

    MySQL Performance Schema

    To check whether performance_schema is available or not.

    # mysqld --verbose --help

    ...

    --performance_schema

    Enable the performance schema.

    --performance_schema_events_waits_history_long_size=#

    Number of rows in events_waits_history_long.

    ...

    To enable it, start the server with the performance_schema variable enabled in the

    my.cnf file.

    mysql > show variables like performance_schema;

  • Remotemysqldba.blogspot.in

    THANK YOU