This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 在一个很大的表内,执行下列2语句,效率一样吗?select count(*) from tableA where condition............
select count(fieldA) from tableA where condition............
The conditions here are same
Thanks
-oceandeep(北极熊·猪真的很快乐);
2003-9-27
{165}
(#1388937@0)
-
The difference is in the second statement only the records with not null fieldA will be counted.
-yangn(Raymond);
2003-9-27
(#1388951@0)
-
啊,我还一直以为结果一样呢,看样子得去试试,谢谢了
-oceandeep(北极熊·猪真的很快乐);
2003-9-27
(#1389033@0)
-
hi, Raymond, what about select count(*) and select count(1) ?Oracle *surprisely* make these two exactly same speed although an Oracle guy INSTIST it is different.
-ra_95(小人--我胡汉三又....);
2003-9-28
{101}
(#1389627@0)
-
对于oracle,我不敢妄言,不过对于SQL Server, count(1) 和 count(*) 是一样的.Count(X) is just counting the number of occurances of whatever is in there. If X is a column, then it counts the nonnull occurances of that column, if its a literal, then it's the same as count(*).
-yangn(Raymond);
2003-9-28
{198}
(#1389683@0)
-
the index will make difference as well.
-leafwind(leafinwind);
2003-9-28
(#1389592@0)
-
if Oracld, please the following statement is better: ' SELECT COUNT(1) FROM ...'
-handd(大熊猫®);
2003-9-29
(#1390256@0)
-
Because the 'COUNT(1)' is counting the 'ROWID'
-handd(大熊猫®);
2003-9-29
(#1390257@0)
-
Sorry, Oracld = ORACLE
-handd(大熊猫®);
2003-9-29
(#1390258@0)