Search Postgresql Archives

Re: Optimizer problem in 8.1.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jun 22, 2007, at 10:16 , Fernando Schapachnik wrote:

Maybe this is already solved in more advanced releases, but just in
case.

VIEW active_users:
SELECT * FROM users WHERE active AND ((field IS NULL) OR (NOT field));

You could also rewrite this as

SELECT *
FROM users
WHERE active
    AND field IS NOT TRUE;

IS NOT TRUE returns true for false and null:

SELECT true IS NOT TRUE AS "true"
    , false IS NOT TRUE AS "false"
    , null IS NOT TRUE AS "null";
true | false | null
------+-------+------
f    | t     | t

This might be a little easier to read.

Michael Glaesemann
grzm seespotcode net




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux