In production, issuing SELECT COUNTcan be a bad idea - it can be a performance hit depending on your database engine. In Oracle, if I want to get an idea of the size of a table without having to resort to COUNT, I can do the following:
SELECT
table_name,
num_rows,
last_analyzed
FROM all_tables
WHERE table_name = 'MY_TABLE_NAME';
This will extract the Oracle table analyzes, if included. While the calculation is not accurate, it can give me an idea of how big the table is if I need to query it (and the last_analysed column lets me know how old this approximation is).
How can I do something like this in SQL Server? (Bound - is it necessary for SQL Server? Oracle should count line by line, therefore, avoid it.)
Thank!
source
share