data_pages

Description

Returns the number of pages used by the specified table, index, or a specific partition. The result does not include pages used for internal structures.

This function replaces data_pgs and ptn_data_pgs from versions of Adaptive Server earlier than 15.0.

Syntax

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

Parameters

dbid

is the database ID of the database that contains the data pages.

object_id

is an object ID for a table, view, or other database object. These are stored in the id column of sysobjects.

indid

is the index ID of the target index.

ptnid

is the partition ID of the target partition.

Examples

Example 1

Returns the number of pages used by the object with a object ID of 31000114 in the specified database (including any indexes):

select data_pages(5, 31000114)

Example 2

(In cluster environments) Returns the number of pages used by the object in the data layer, regardless of whether or not a clustered index exists:

select data_pages(5, 31000114, 0)

Example 3

(In cluster environments) Returns the number of pages used by the object in the index layer for a clustered index. This does not include the pages used by the data layer:

select data_pages(5, 31000114, 1)

Example 4

Returns the number of pages used by the object in the data layer of the specific partition, which in this case is 2323242432:

select data_pages(5, 31000114, 0, 2323242432)

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute data_pages.

See also

Functions object_id, row_count

System procedure sp_spaceused