OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: Indexing and no values

From: Jigal van Hemert (jigalspill.nl)
Date: Mon Oct 03 2005 - 05:16:11 CDT


Gleb Paharenko wrote:
> I'm not giving an exact answer on your question, however, it might be
> interesting for you. Usually queries are faster if you define the column as NOT NULL.

What's the reason behind this? NULL 'values' are a bit of strange
phenomenon. In the EXPLAIN output a query with WHERE <col> NOT NULL; is
of type 'range', which implies that NULL has a position in the range of
values of the column. On the other hand UNIQUE indexes allow multiple
NULL 'values' (except for BDB tables) and the storage space for various
data types does not leave room for an extra 'value' in the range.

It almost seems as if NULL is stored as a kind of prefix in an index?

Regards, Jigal.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql