Re: Optimizer problem in 8.1.6 - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: Optimizer problem in 8.1.6
Date
Msg-id 3C6C435F-C850-4814-BCDF-3D2B731DADD9@seespotcode.net
Whole thread Raw
In response to Optimizer problem in 8.1.6  (Fernando Schapachnik <fernando@mecon.gov.ar>)
List pgsql-general
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



pgsql-general by date:

Previous
From: "Charles Mortell"
Date:
Subject: How determine a Views dependents
Next
From: Tzahi Fadida
Date:
Subject: Re: 8.2 contrib. "Full Disjunction"