Slide 20
Slide 20 text
Mimando a MySQL @_alvaromg
Explain
type: Cómo MySQL hace join con esta tabla. Posibles valores:
● system: La tabla tiene 0 o 1 registros.
● const: La tabla solo tiene 1 registro y cubierto por algún
índice.
● eq_ref: Se usa completamente algún índice y éste es
PRIMARY o UNIQUE NOT NULL.
● ref: Se leen todos los registros de un índice.
● fulltext: se usa algún índice FULTEXT.
● ref_or_null: Igual que "ref", pero contiene valores NULL.
● index_merge: Se usan varios índices.
unique_subquery: Subconsulta IN con 1 solo resultado.
● index_subquery: similar a unique_subquery pero más
de 1 resultado.
● range: Usa un rango del índice. Normalmente al usar
BETWEEN, IN, >, >=, etc
● index: Se recorre el índice completo.
● all: Se recorre toda la tabla. Es el caso más lento y hay
que evitarlo.
EXPLAIN SELECT p.id, p.name, c.name
FROM Programs p
INNER JOIN Categories c
ON p.category_id = c.id
WHERE c.id = 401
AND p.banned = 0\G
****** 1. row *************
id: 1
select_type: SIMPLE
table: c
type: const
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: const
rows: 1
Extra:
****** 2. row *************
id: 1
select_type: SIMPLE
table: p
type: index_merge
possible_keys: IDX_83F,idx_banned
key: IDX_83F,idx_banned
key_len: 5,1
ref: NULL
rows: 46
Extra: Using intersect(IDX_83F,
idx_banned); Using where
2 rows in set (0.00 sec)