Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

explain

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

like image 610
sanchitkhanna26 Avatar asked Feb 19 '13 08:02

sanchitkhanna26


1 Answers

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

like image 126
Bhavik Shah Avatar answered Sep 24 '22 15:09

Bhavik Shah