mysql.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 10 Feb 2018 01:28:53 +0200
changeset 2227 1e9323e7ec88
parent 1912 8b81a8f0f692
child 2228 837f1337c59b
permissions -rw-r--r--
Removed files: I don't longer have interest on topic.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1809
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
.. -*- coding: utf-8; -*-
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
================
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
 MySQL/MariaBD.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
================
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
.. contents::
1905
fba288d59662 Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1880
diff changeset
     7
   :local:
1809
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
SQL clients.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
============
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
1810
752c192306ff SQL clients.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1809
diff changeset
    12
  https://mariadb.com/kb/en/mariadb/clients-and-utilities/
752c192306ff SQL clients.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1809
diff changeset
    13
     Clients and Utilities.
752c192306ff SQL clients.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1809
diff changeset
    14
  https://mariadb.com/kb/en/mariadb/graphical-and-enhanced-clients/
752c192306ff SQL clients.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1809
diff changeset
    15
     Graphical and Enhanced Clients.
752c192306ff SQL clients.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1809
diff changeset
    16
1809
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
mysql.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
------
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
Official client. Install ``mariadb-client`` package - ``mysql`` utility
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
will be installed with dependent package.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
Usage::
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
  $ mysql -u $USER -p
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
  Enter password:   <== Type password.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
1851
e6ffc5f7200e To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1850
diff changeset
    28
To save content of session interaction in ``mysql`` use::
e6ffc5f7200e To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1850
diff changeset
    29
e6ffc5f7200e To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1850
diff changeset
    30
  mysql> tee out.txt
e6ffc5f7200e To save content of session interaction.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1850
diff changeset
    31
1809
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    32
mycli.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
------
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
Python command line client with completion. Usage::
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    36
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
  $ mycli -u $USER
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
  Password:         <== Type password.
4e78b58a2935 MySQL/MariaBD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
1880
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    40
List databases, tables, columns, indexes.
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    41
=========================================
1811
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    42
::
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    43
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    44
  $ mysql -u $USER -p
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    45
  Enter password:   <== Type password.
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    46
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    47
  SHOW DATABASES;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    48
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    49
  USE mysql;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    50
  MariaDB [mysql]> SHOW TABLES;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    51
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    52
  MariaDB [mysql]> SHOW COLUMNS FROM user;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    53
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    54
  MariaDB [mysql]> DESCRIBE user;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    55
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    56
  MariaDB [mysql]> SHOW STATUS;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    57
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    58
  MariaDB [mysql]> SHOW CREATE DATABASE mysql;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    59
  MariaDB [mysql]> SHOW CREATE TABLE user;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    60
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    61
  MariaDB [mysql]> SHOW GRANTS;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
    62
1880
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    63
List indexes::
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    64
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    65
  SELECT * FROM INFORMATION_SCHEMA.STATISTICS;
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    66
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    67
  SHOW INDEX FROM tbl;
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    68
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    69
  SHOW INDEX FROM tbl FROM db;
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    70
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    71
  SHOW CREATE TABLE tbl;
ff2e0241303c List indexes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1879
diff changeset
    72
1877
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    73
Table/index sizes.
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    74
==================
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    75
::
1876
653a83760554 Table sizes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1875
diff changeset
    76
653a83760554 Table sizes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1875
diff changeset
    77
  MariaDB [mysql]> SHOW TABLE STATUS FROM mydb;
653a83760554 Table sizes
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1875
diff changeset
    78
1878
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    79
::
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    80
1877
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    81
  SELECT
1878
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    82
    table_schema "Database",
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    83
    ROUND(SUM(data_length+index_length)/1024/1024, 2) "Size, MiB"
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    84
  FROM information_schema.TABLES
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    85
  GROUP BY table_schema;
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    86
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    87
  SELECT
1879
b5f927fa28ce Add row count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1878
diff changeset
    88
    table_schema AS `Database`,
b5f927fa28ce Add row count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1878
diff changeset
    89
    table_name,
b5f927fa28ce Add row count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1878
diff changeset
    90
    table_rows,
1878
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    91
    round(((data_length + index_length) / 1024 / 1024), 2) `Size, MiB`
1877
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    92
  FROM information_schema.TABLES
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    93
  ORDER BY (data_length + index_length) DESC;
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    94
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
    95
  SELECT
1878
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    96
    table_schema as `Database`,
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    97
    table_name AS `Table`,
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    98
    round((data_length / 1024 / 1024), 2) `Data, MiB`,
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
    99
    round((index_length / 1024 / 1024), 2) `Index, MiB`,
25c0fb1dfc22 DB sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1877
diff changeset
   100
    round(((data_length+index_length) / 1024 / 1024), 2) `Total, MiB`
1877
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
   101
  FROM information_schema.TABLES
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
   102
  ORDER BY (data_length + index_length) DESC;
7627e51556bf Table/index sizes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1876
diff changeset
   103
1849
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   104
System information.
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   105
===================
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   106
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   107
Server version, platform, etc::
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   108
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   109
  [mysql]> SHOW VARIABLES LIKE "%version%";
a3b639d803e7 System information.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1836
diff changeset
   110
1850
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   111
Debugging queries error.
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   112
========================
1836
4864231db031 Debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1811
diff changeset
   113
4864231db031 Debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1811
diff changeset
   114
After error or warning run::
4864231db031 Debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1811
diff changeset
   115
1811
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
   116
  MariaDB [mysql]> SHOW WARNINGS;
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
   117
  MariaDB [mysql]> SHOW ERRORS;
1836
4864231db031 Debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1811
diff changeset
   118
  MariaDB [mysql]> show engine innodb status;
1811
072cc8a704ce List databases, tables, columns.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1810
diff changeset
   119
1854
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   120
Debugging quiery performance.
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   121
=============================
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   122
::
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   123
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   124
  explain select 1;
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   125
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   126
..
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   127
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   128
  https://mariadb.com/kb/en/mariadb/explain/
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   129
    Syntax and transcription of EXPLAIN.
9b224b68c1e1 Debugging quiery performance.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1853
diff changeset
   130
1850
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   131
Monitor server execution.
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   132
=========================
1852
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   133
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   134
List all current executions::
1850
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   135
1852
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   136
  MariaDB [mysql]> show processlist;
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   137
1875
340162fb09a2 Stop selected process
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1854
diff changeset
   138
Stop selected process::
340162fb09a2 Stop selected process
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1854
diff changeset
   139
340162fb09a2 Stop selected process
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1854
diff changeset
   140
  MariaDB [mysql]> kill 12;
340162fb09a2 Stop selected process
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1854
diff changeset
   141
1852
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   142
Dump execution plan for selected process::
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   143
f572f646694b Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1851
diff changeset
   144
  MariaDB [mysql]> show explain for 1;
1850
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   145
1853
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   146
.. NOTE::
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   147
   You shoud check for code ``1003``::
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   148
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   149
     MariaDB [mysql]> show warnings;
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   150
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   151
   to ensure for which query plan shown becase query may finished and new
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   152
   started.
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   153
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   154
See:
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   155
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   156
 * `SHOW EXPLAIN in MariaDB 10.0 vs EXPLAIN FOR CONNECTION in MySQL 5.7
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   157
   <http://s.petrunia.net/blog/?p=89>`_
c6be6cc87df4 Dump execution plan for selected process.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1852
diff changeset
   158
1850
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   159
Profiling queries.
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   160
==================
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   161
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   162
Enable profiling, execute query and review profiling data::
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   163
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   164
  [mysql]> set profiling=1;
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   165
  [mysql]> select 1;
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   166
  [mysql]> show profile;
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   167
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   168
Each profiled query results stored separately. To get list of results::
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   169
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   170
  [mysql]> show profiles;
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   171
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   172
To retrieve selected profiling data::
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   173
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   174
  [mysql]> show profile for query 1;
84707c692266 Monitor server execution. Profiling queries.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1849
diff changeset
   175