This is normal behavior based on engineering's information, but there is a "
not exists" workaround if needed. We have two tables that share a text key:
CREATE TABLE table1(key text not null);
CREATE TABLE table2(key text not null);
Table1 contains
11822664 distinct keys and
table2 contains
11674868 distinct keys. The result of the following query is zero:
SELECT COUNT(DISTINCT key)
FROM table1
WHERE key NOT IN (SELECT key FROM table2);
Note:
table1 has more distinct keys than
table2.
Furthermore, the following query returns the correct result:
SELECT COUNT(DISTINCT table1.key)
FROM table1
LEFT JOIN table2 ON table1.key = table2.key
WHERE table2.key IS NULL;
The result is:
5593730