Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbsYJ-0001rQ-8X for pgsql-general@arkaria.postgresql.org; Tue, 05 Apr 2022 23:25:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbsYH-00042A-5F for pgsql-general@arkaria.postgresql.org; Tue, 05 Apr 2022 23:25:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbsYE-00041z-Go for pgsql-general@lists.postgresql.org; Tue, 05 Apr 2022 23:25:32 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbsYA-0005By-OD for pgsql-general@lists.postgresql.org; Tue, 05 Apr 2022 23:25:29 +0000 Received: by mail-qt1-x82a.google.com with SMTP id t2so1725488qtw.9 for ; Tue, 05 Apr 2022 16:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=1EOs3aIUdC8O3dil9VJqYk7rcYoL62ThIM00FL4hTbo=; b=TmqRUotE+JnIROP9DNDB/fwySOD3YRQhEJkC+Q3Jh9wwHnmOQ5fYYzjmWsq7m3sGhX 9ANLlXhek8WmI/UrRmk+99aG0X/H2QvaC0EbnwWn7QgYE7XvQwT7V4+mEAGNravwTsFh 3uV4ZkNNvB7CpRnTieS8T01bKiBylwRX0wKQnjBcZR5UOrRNdFlUOHbSh8uP7astfSnN PVgs5J4cjcImLjVzgK5ozegeEg9X1y/hMYEPRWiKpLlS2kaOBdpa0TIVRddVrttXKk0D av1kPUoPtjAy/bkhWFs9r1J1XpQdN3BGwJSckbJFAwgjb5nFDr4ukPcU69l5rw3238ap uW/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=1EOs3aIUdC8O3dil9VJqYk7rcYoL62ThIM00FL4hTbo=; b=GmjKsoV6ietkNayUCATyh7ex9t1bYyBwq5YFExBjP7qhwWh22AVnSpgWQeDM8mjrc4 YRHcdUu2XN7SD/dMtyaDWg73ED3yVITo1kGdAphiEUS7De0dq0sh7nX1Gz9GTqPA9Uy/ stqrWxGfWubQvIOgWNRsEQc5dyGMjOBICAeniNPTZDVjznBHSa7srj1XlYQuE66gsKGL dvQoWAHaJxr8viWfoa7RtHk9G3cLkCY/B6qoe+GMDiS9pM+IzPZRNUrTmn1wyjZcVh+K G6cJT+r8CW//IKYqXCohQV6hhewRGoP8cFPZW265qa+T1dmE0OG1lqF8ZunA92cQPRsw cATg== X-Gm-Message-State: AOAM531rUK8GXIfltfC59yW/ABAz/6gXKem4RzOKxrv9SG8QbjcVrTor zSDh2RopmUTYMdZJasSgUtbmsLLEPyBIWw== X-Google-Smtp-Source: ABdhPJySFw/n1fI83vxVnZ0OfY1mANTK1Mlk8MRZItw1BtqWg12eUAnRZkyPY0BZADl5HUJ9RaSdfA== X-Received: by 2002:a05:622a:3c7:b0:2e1:d537:a15a with SMTP id k7-20020a05622a03c700b002e1d537a15amr5419426qtx.522.1649201125441; Tue, 05 Apr 2022 16:25:25 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id q8-20020a05622a04c800b002e06d7c1eabsm11999071qtx.16.2022.04.05.16.25.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 16:25:25 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------8SFj6IlcxbGQMsHJj33Et0KU" Message-ID: <71a6ae74-79ca-09c6-2e9c-a7f4d86b176f@gmail.com> Date: Tue, 5 Apr 2022 19:25:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Select .... where id not in (....) returns 0 incorrectly Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <5820573.lOV4Wx5bFT@iris> <2ddba2d73d0d54da3396ff2dad9e7d2d@vivaldi.net> <2245474.ElGaqSPkdT@iris> From: Mladen Gogala In-Reply-To: <2245474.ElGaqSPkdT@iris> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------8SFj6IlcxbGQMsHJj33Et0KU Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/4/22 09:21, J. Roeleveld wrote: > This was actually the case, I forgot there is 1 NULL-value in that list. > Personally, I think NULL should be treated as a seperate value and not lead to > strange behaviour. NULL is strange. Relational databases use ternary, not binary logic. In the woke vernacular, one could say that Postgres is non-binary. NULL literally means "no value". It is a part of the standard, so we have to deal with it, Codd help us. However, based on my lifelong experience with Oracle, NULL values are bad and are best avoided. Postgres is more forgiving than Oracle because in Postgres, the condition "is not null" can be resolved by index. In Oracle, it can not. -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------8SFj6IlcxbGQMsHJj33Et0KU Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 4/4/22 09:21, J. Roeleveld wrote:
This was actually the case, I forgot there is 1 NULL-value in that list.
Personally, I think NULL should be treated as a seperate value and not lead to 
strange behaviour.

NULL is strange. Relational databases use ternary, not binary logic. In the woke vernacular, one could say that Postgres is non-binary. NULL literally means "no value". It is a part of the standard, so we have to deal with it, Codd help us. However, based on my lifelong experience with Oracle, NULL values are bad and are best avoided. Postgres is more forgiving than Oracle because in Postgres, the condition "is not null" can be resolved by index. In Oracle, it can not.

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------8SFj6IlcxbGQMsHJj33Et0KU--