Re: Select count(*)
Posted in 1993
Topics: Performance & Tuning, SQL Development & Query Writing
Under OnLine, the value of nrows is only updated by update statistics.
If you don't do that on a periodic basis, then it may be quite outdated.
Update Statistics also updates the LEVELS, LEAVES, NUNIQUE, and CLUSTcolumns for sysindexes for each index of a table. This is why it takes
so long to run update statistics. The optimizer uses these columns to
determine the quality of an index.
Select COUNT(*) always returns the correct number of rows for a table atthe instant that you run it. If your select statement is simple (only
one table) then it reads the value for number of rows from the table's
RSAM header. It doen't need to go out to rows and count them.
If you want to find out some of the other goodies stored in the RSAM
header to a "tbcheck -pT <database>:<table>" on the table. It includes
row size in bytes, pages allocated, current serial value, and more.
--
Take Care --
Eric
-----------------------------------------------------------------------------
AMAZING BUT TRUE...
There is so much sand in Northern Africa that if it were spread out it
would completely cover the Sahara Desert.