EXPLAIN nello Slow Query Log

Nota: questa pagina descrive una funzionalità che si trova in una versione Alpha di MariaDB. E' possibile che alcuni cambiamenti vengano apportati.

A partire da MariaDB 10.0.5, è possibile scrivere l'output di EXPLAIN nello slow query log.

Attivarlo

EXPLAIN può essere attivato specificando la parola chiave "explain" nella variabile di sistema log_slow_verbosity. In alternativa, è possibile specificarla nell'argomento da riga di comando log-slow-verbosity.

[mysqld]
log-slow-verbosity=query_plan,explain

Come appare

Quando la scrittura di explain è attiva, le voci dello slow query log assomigliano alla seguente:

# Time: 131017 21:26:02
# User@Host: root[root] @ localhost []
# Thread_id: 2  Schema: dbt3sf1  QC_hit: No
# Query_time: 5.535819  Lock_time: 0.000350  Rows_sent: 1  Rows_examined: 65633
## <explain>
##   id select_type     table   type    possible_keys   key     key_len ref     rows    Extra
##   1  SIMPLE  nation  ref     PRIMARY,n_name  n_name  26      const   1       Using where; Using index
##   1  SIMPLE  customer        ref     PRIMARY,i_c_nationkey   i_c_nationkey   5       dbt3sf1.nation.n_nationkey      25124   Using index
##   1  SIMPLE  orders  ref     i_o_custkey     i_o_custkey     5       dbt3sf1.customer.c_custkey      7       Using index
## </explain>
SET timestamp=1382030762;
select count(*) from customer, orders, nation where c_custkey=o_custkey and c_nationkey=n_nationkey and n_name='GERMANY';

EXPLAIN è delimitato da <explain> ... </explain> e inizia con un doppio ## per facilitare l'uso di grep.

Vedi anche

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.