Question: We assume that there is no primary key defined for a table T. In that case, how does one count all the rows in T quickly/efficiently for these databases - Oracle 11g, MySql, Mssql ?

It seems that count(\*) and count(column\_name) can be slow and inaccurate respectively. The following seems to be the fastest and most reliable way to do it-

```
select count(rowid) from MySchema.TableInMySchema;

```

Can you tell me if the above statement also has any shortcomings ? If it is good, then do we have similar statements for mysql and mssql ?

Thanks in advance.

Source - 
<http://www.thewellroundedgeek.com/2007/09/most-people-use-oracle-count-function.html>

Answer: 
In Oracle, `COUNT(*)` is the most efficient. Realistically, `COUNT(rowid)`, `COUNT(1)`, or `COUNT('fuzzy bunny')` are likely to be equally efficient. But if there is a difference, `COUNT(*)` will be more efficient.
i *EVER* use `SELECT COUNT(1) FROM anything;`, instead of the asterisk...

some people are of the opinion, that mysql uses the asterisk to invoke the query-optimizer and ignores any optimizing when use of "1" as static scalar...

imho, this is straight-forward, because you don't use any variable and it's clear, that you only count all rows.