|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Michael Dykman (mdykman
gmail.com)
Date: Mon Dec 28 2009 - 13:35:19 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
No, nothing will ever equal null. In strict relational theory, which I
don't know well enough to begin expounding on here, null does not even
equal another null. That's why SQL provides IS NULL and IS NOT NULL
as explicit cases.
- michael dykman
On Mon, Dec 28, 2009 at 2:32 PM, D. Dante Lorenso <dante
lorenso.com> wrote:
>
> Will anything ever be equal to NULL in a SELECT query?
>
> SELECT *
> FROM sometable
> WHERE somecolumn = NULL;
>
> I have a real-life query like this:
>
> SELECT *
> FROM sometable
> WHERE somecolumn = NULL OR somecolumn = 'abc';
>
> The 'sometable' contains about 40 million records and in this query, it
> appears that the where clause is doing a sequential scan of the table to
> find a condition where 'somecolumn' = NULL. Shouldn't the query parser be
> smart enough to rewrite the above query like this:
>
> SELECT *
> FROM sometable
> WHERE FALSE OR somecolumn = 'abc';
>
> And therefor use the index I have on 'somecolumn'? When I manually rewrite
> the query, I get the performance I expect but when I leave it as it was,
> it's 100 times slower.
>
> What's so special about NULL?
>
> -- Dante
>
> ----------
> D. Dante Lorenso
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=mdykman
gmail.com
>
>
--
- michael dykman
- mdykman
gmail.com
"May you live every day of your life."
Jonathan Swift
Larry's First Law of Language Redesign: Everyone wants the colon.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]