DEV Community

Estevez Ben Lajamin
Estevez Ben Lajamin

Posted on

Query Explain Type

ALL: This type indicates a full table scan where no index is used. It’s generally the slowest option since it scans the entire table.

index: This type represents a full index scan, meaning the entire index is scanned rather than just part of it. It's faster than a full table scan but can still be slow for large indexes.

range: Used for range queries, this type indicates that a range scan is being used on the index. It's more efficient than a full table scan for queries involving ranges.

ref: This type is used when a non-unique index is used to retrieve rows that match a single value or a set of values. It's more efficient than ALL or index for certain queries.

eq_ref: Indicates the use of a unique index where the query matches a single row. It’s very efficient for queries that involve unique indexes.

const: This type is optimized for queries using a primary key or unique index. It’s very fast as it typically returns at most one row.

unique_subquery: This type is used when a unique index is utilized within a subquery. It’s efficient for subqueries with unique constraints.

fulltext: This type shows that a full-text index is being used, which is optimized for text search operations.

primary: Indicates that the primary key index is being used, which is typically the most efficient method for primary key lookups.

Top comments (0)