A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: System Functions

used_pages()

The system function used_pages() returns the number of used pages of a table, partition or index. In contrast to the function data_pages(), the return value of the function used_pages also contains pages used for ASE internal structures. The function used_pages replaces the system function used_pgs starting with ASE version 15.0. used_pages(dbid, objid, 0) returns the same result as used_pages(dbid, objid, 1), if a table with all-page lock scheme and a clustered index is queried. This is comparable to the earlier version of used_pgs(objid, doampg, ioampg). All erroneous results are covered by a return value of "0". The system function "used_pages()" is a T-SQL extension. It can be executed by any user.

Syntax of the System Function used_pages()

    used_pages(dbid, object_id [, indid , ptnid])
    

The parameters of the System Function used_pages()

"dbid"
The parameter "dbid" id the id (identification number) of the database in which the object is stored. The dbid can be located in the column "dbid" of the system table sysdatabases.

"object_id"
The parameter "object_id" is the identification number of the object, i.e. of the table for which used_pages must determine the usage data. The "object_id" can be retrieved from the column id of the system table sysobjects. In order to determine the number of pages used by an index, specify the "object_id" of the table to which the index belongs.

"indid"
The parameter "indid" describes the identification number of the index to be queried. The "indid" is located in the column "indid" of the system table sysindexes.

"ptnid"
The parameter "ptnid" is the identification number of the partition to be queried. The "ptnid" is the value stored in the column "partitionid" of the system table syspartitions.

Example for the System Function used_pages()

    1> select used_pages(1,960003420)
    2> go
    
    -----------
             37

    (1 row affected)

    

Returns the number of used pages in the table with the id 960003420 ("spt_values") in the "master" database.

    1> select used_pages(1,960003420,0)
    2> go

    -----------
             35

    (1 row affected)
    

Returns the number of used pages in the data segment of the table, irrespective if a "clustered index" exists or not

    1> select used_pages(1,960003420,1)
    2> go

    -----------
             37

    (1 row affected)
    

Returns the number of used pages in the index segment of a table. The pages of the data segment are not included.

    1> select used_pages(1,1616005757,0,1616005757)
    2> go

    -----------
              3

    (1 row affected)
    

Returns the number of used pages of the object on the datasegment of the specified partition (1616005757)

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(),
row_count(),
showplan_in_xml(),
syb_sendmsg(),
syb_sendmsg(),
System Functions,
tempdb_id(),
tran_dumpable_status(),
tsequal(),
used_pgs().