Databasen - NULL dates
Paul Makepeace
paulm at paulm.com
Thu Oct 19 12:48:00 BST 2006
On 10/19/06, Peter Corlett <abuse at cabal.org.uk> wrote:
> On Thu, Oct 19, 2006 at 09:22:32AM +0100, Jacqui Caren wrote:
> > Null is correct for this usage however often NULL cannot be indexed and a
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> That's very much down to the implementation, but in a sane database, you'll
> find that you rarely need to look for NULLs for most queries. After all,
> "foo = NULL" is always false, so NULL columns can't participate in joins.
Er, try inverting it and/or using LEFT JOINs and feel the pain.
Jacqui's comment is the first here that actually delves much deeper
than "NULL is undef so r0xor!" and she has good points.
This isn't implementation specific; it's part of SQL behaviour, and
it's a pain in the ass -- it's worth avoiding NULLs wherever
non-trivial queries are involved.
P
> You can always use an explicit "foo IS NULL" expression index if it turns
> out that you're doing that kind of query regularly.
>
> If you mean that your RDBMS cannot put an index on a column that isn't
> marked NOT NULL, I suggest you find something better.
>
>
More information about the london.pm
mailing list