这让我大吃一惊。
我想要做的就是在varchar
字段上进行基本的字符串比较。
我有一张大约一张桌子。 12M记录。
如果我查询MY_FIELD='a string'
,我的计数为25947,这似乎是正确的。
如果我查询MY_FIELD!='a string'
,我的计数为989。
这两个计数不应该加起来是12M的完整表格大小吗?
答案 0 :(得分:6)
这些行中有多少行MY_FIELD
设置为NULL
?
a. select count(*) from mytable;
b. select count(*) from mytable where my_field is null;
c. select count(*) from mytable where my_field is not null;
d. select count(*) from mytable where my_field = 'some value';
e. select count(*) from mytable where my_field != 'some value';
NULL
与任何值不相等或不相等,包括NULL
因此我希望d+e
等同于c
和{{ 1}}等同于b+c
。