Hi,

I am getting copies of your email...I don't know why...Can you fix this problem..

Kind regards,
Matthew
----- Original Message ----- From: "Mark Goodge" <[EMAIL PROTECTED]>
To: "mysql" <mysql@lists.mysql.com>
Sent: Monday, November 17, 2008 10:14 AM
Subject: Re: Optimizing nullable expiration dates




Norman Elton wrote:
I've got a table that tracks expiration dates. Currently, if the
record hasn't expired, the column is stored as NULL. In order to find
records that haven't expired, I search for "WHERE expire_at > NOW() OR
expire_at IS NULL". This seems dirty, and I suspect it makes my
indexes very angry.

I suppose I could pick some arbitrary future date (Dec 31 2999) to use
in place of NULL.

Is there a better way? Surely I'm not the first to run into this!

If the field is only updated when the record expires, then a simple "where expire_at is NULL" will do. You only need to compare expiration dates with NOW() if they can be in the future - which, from your description, isn't possible.

If an expiry date can be either future, past or non-existent, then your existing selector is as good as any.

Mark
--
http://mark.goodge.co.uk - my pointless blog
http://www.good-stuff.co.uk - my less pointless stuff

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to