2 messages in com.mysql.lists.mysqlRe: optimizing "not empty" selections
FromSent OnAttachments
Michael Monashev26 Jul 2005 13:41 
SGr...@unimin.com26 Jul 2005 14:17 
Subject:Re: optimizing "not empty" selections
From:SGr...@unimin.com (SGr@unimin.com)
Date:07/26/2005 02:17:48 PM
List:com.mysql.lists.mysql

Michael Monashev <mich@softsearch.ru> wrote on 07/26/2005 04:41:28 PM:

Hello,

How to optimize != statement?

SELECT * FROM table1 WHERE char_255_column != '';

How to fast select all rows, where CHAR(255) NOT NULL column not empty?

Sincerely, Michael,

You could try

WHERE char_255_column > ''

If the field has any text in it at all, the comparison will be true. Also, since this is a ranged comparison, you give the optimizer the opportunity to use an index if one is available.

Shawn Green Database Administrator Unimin Corporation - Spruce Pine