Extra in EXPLAIN printing - 'Impossible WHERE noticed after reading const tables'
Asked Answered
H

1

8

I have a simple table called 'million_words'. It has one row with two columns -> id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY & word VARCHAR(50 NOT NULL.

I run this query -: EXPLAIN SELECT * FROM million_words WHERE word = '-anon'

The Extra column then prints : 'Impossible WHERE noticed after reading const tables, even though the row is clearly present in the table.

Whats wronf

Halsey answered 19/2, 2013 at 8:57 Comment(0)
T
15

From MySQL documentation:

"Impossible WHERE noticed after reading const tables":
MySQL has read all const (and system) tables and notice that the WHERE clause is always false. Refer this


The table has at most one matching row, which is read at the start of the query. Because there is only one row, values from the column in this row can be regarded as constants by the rest of the optimizer. const tables are very fast because they are read only once.

const is used when you compare all parts of a PRIMARY KEY or UNIQUE index to constant values. Refer this

Trueman answered 19/2, 2013 at 9:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.