On 28-8-2011 4:08, shawn wilson wrote:
> On Sat, Aug 27, 2011 at 17:33, Arthur Fuller<fuller.artful@stripped> wrote:
>> I agree 110%. It is completely pointless to index a column with that amount
>> of NULLs. In practical fact I would go further: what is the point of a
>> NULLable column?
A NULL 'value' is special in most operations. It indicates that the
value is undefined, unknown, uncertain. In this regard it's actually not
SELECT 'Uncertain' = TRUE;
SELECT 'Uncertain' = FALSE;
SELECT 'Uncertain' = NULL;
SELECT NULL = TRUE;
SELECT NULL = FALSE;
SELECT NULL = NULL;
(Unfortunately someone decided to add the <=> operator:
SELECT NULL <=> NULL;
Even stranger is that it is documented as "NULL safe" !?!?)
The advantage to me for having NULL 'values' is that it is usually
handled as a truly undefined value. (When you compare an undefined value
with for example 2, the result cannot be TRUE or FALSE. The undefined
value might be equal to 2, or might not be equal to 2. The result can
only be undefined.)
To deal with NULL results inside expressions COALESCE() is a very useful
> how does null effect an index? i had always assumed that, since there
> is nothing there, that record wouldn't go into the index hence
> wouldn't be processed when utilizing the index.
MySQL can use NULL in indexes when executing a query. If there are not
enough different values in a column (low cardinality) it might be faster
to do a full table search instead of first reading the index and then
having to go through the table anyway.
Kind regards / met vriendelijke groet,
Jigal van Hemert.