SHOW EXPLAIN

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Ecco una documentazione preliminare di SHOW EXPLAIN.

Sintassi

Assomiglia alla seguente:

MariaDB [test]> show explain for 1;
+------+-------------+-------+-------+---------------+------+---------+------+---------+-------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows    | Extra       |
+------+-------------+-------+-------+---------------+------+---------+------+---------+-------------+
|    1 | SIMPLE      | tbl   | index | NULL          | a    | 5       | NULL | 1000107 | Using index |
+------+-------------+-------+-------+---------------+------+---------+------+---------+-------------+
1 row in set, 1 warning (0.00 sec)

MariaDB [test]> show warnings;
+-------+------+------------------------+
| Level | Code | Message                |
+-------+------+------------------------+
| Note  | 1003 | select sum(a) from tbl |
+-------+------+------------------------+
1 row in set (0.00 sec)

Il codice

Il codice più recente è qui:

https://code.launchpad.net/~maria-captains/maria/5.5-show-explain

Differenze dall'output di EXPLAIN

In MySQL, esistono porzioni di codice in cui l'esecuzione di EXPLAIN segue un percorso differente rispetto all'esecuzione effettiva. Quando si esegue SHOW EXPLAIN su una query SELECT, esamina altre strutture dati e quindi l'output potrebbe risultare leggermente diverso.

Qualcuno potrebbe obiettare che l'output di SHOW EXPLAIN è l'unico corretto. In seguito EXPLAIN produrrà lo stesso output di SHOW EXPLAIN.

Segue l'elenco delle differenze:

  • SHOW EXPLAIN potrebbe produrre righe di EXPLAIN con il valore no matching row in const table nella colonna EXTRA, laddove EXPLAIN avrebbe prodotto un Impossible WHERE ...:
  1      SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    no matching row in const table
  • Per le query che vengono convertite dall'ottimizzatore in una sola select, il select_type potrebbe diventare PRIMARY, laddove EXPLAIN mostrava SIMPLE.

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.