On Feb 26, 2010, at 0:55 , Дмитрий Фефелов wrote:

http://developer.postgresql.org/pgdocs/postgres/release-9-0.html

Performance section:

Simplify the forms foo <> true and foo <> false to foo = false and
foo = true during query optimization.

Will it work correct;ly when foo is NULL?

It shouldn't have any effect: NULL <> anything and NULL = anything is NULL

SELECT arg1, arg2,
       (arg1 <> arg2) AS "arg1 <> arg2",
       (arg1 = arg2) AS "(arg1 = arg2)"
  FROM (VALUES (TRUE, TRUE), (TRUE, FALSE),
               (FALSE, TRUE), (FALSE, FALSE),
               (NULL, TRUE), (NULL, FALSE)) AS bools (arg1, arg2)
  ORDER BY arg1, arg2;

  arg1  | arg2 | arg1 <> arg2 | (arg1 = arg2)
--------+------+--------------+---------------
 f      | f    | f            | t
 f      | t    | t            | f
 t      | f    | t            | f
 t      | t    | f            | t
 (null) | f    | (null)       | (null)
 (null) | t    | (null)       | (null)
(6 rows)

Michael Glaesemann
grzm seespotcode net




--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to