|
row_count()
The
system function
rowcount()
returns an estimate of the number of
rows
in a given
table.
The return value is not determined by scanning the whole table, but using the
object allocation map,
or short
OAM Page
of the table. The received value is mostly correct, but can be distorted by frequent
insert
or
delete
statements, if
ASE
is rebooted, or when recovering
transactions.
The value is exact after running one of the following commands:
-
dbcc checkalloc
-
dbcc checkdb
-
dbcc checktable
-
update all statistics
-
update statistics
The system function "row_count()" replaces the function
rowcnt()
starting with ASE version 15.0.
The function "row_count()" can be executed by any
user.
Syntax of the System Function row_count()
rowcnt(dbid, object_id [, ptnid])
The parameter of the System Function row_count()
Starting with ASE version 15.0, the parameters "doampg" and "ioampg"
are replaced by more user friendly parameters "indid" and "ptnid".
In earlier versions space allocations were monitored using the
system table
sysindexes.
In version 15.0, this task is shifted to the system table
syspartitions.
"dbid"
The parameter "dbid" is the identification number of the database in which the target
object is stored. The dbid of a database can be found in the
column
dbid of the system table
sysdatabases.
"object_id"
The parameter "object_id" describes the identification number of the table
being queried. The "object_id" is located in the column id
of the system table
sysobjects.
"ptnid"
The optional parameter "ptnid" is the identification number of the desired
partition.
The "ptnid" can be retrieved from the column partitionid of the system table
syspartitions.
Example for the System Function row_count()
select row_count(5, 31000114, 2323242432)
The return value is the estimated number of rows in the partition with the id 2323242432,
in the object with id 31000114, stored in the database with the id 5.
See also:
ASE T-SQL - Aggregate Functions, audit_event_name(), col_length(), col_name(), curunreservedpgs(), datachange(), datalength(), data_pages(), data_pgs(), db_id(), db_name(), host_id(), host_name(), identity(), index_col(), index_colorder(), isnull(), lct_admin(), license_enabled(), lockscheme(), next_identity(), object_id(), object_name(), pagesize(), pointer_size(), ptn_data_pgs(), reserved_pages(), reserved_pgs(), rowcnt(), showplan_in_xml(), syb_sendmsg(), syb_sendmsg(), System Functions, tempdb_id(), tran_dumpable_status(), tsequal(), used_pages(), used_pgs().
|