This chapter discusses how to calculate the disk space needed for the various files and operations of an Ingres installation.
An Ingres installation requires disk space for storing the system executables as well as for data tables. Disk space is also used during the execution of many commands. Adequate resources are needed for the user account of the installation owner, for the DBA, and for the end users to ensure that the installation is free of problems due to inadequate disk space.
This section defines terms applicable to page size and gives calculations for estimating the amount of disk space needed for tables. These are approximations—your table can be much larger, depending on compression and the size of key values.
The calculations are based on newly modified tables. Using the number of rows in the table to determine table size becomes less accurate after data has been deleted or added.
VDBA provides a calculation tool that allows you to calculate disk space requirements for any storage structure quickly and easily. For procedures, see online help.
Note: If rows in the table span pages, use the procedure in Calculate Space Requirements When Rows Span Pages instead.
Use the following procedure to determine the amount of space needed to store the data in a heap table:
select tups_per_page from iitables where table_name = 'tablename';
total_heap_pages = num_rows / tups_per_page
Note: If rows in the table span pages, use the procedure in Calculate Space Requirements When Rows Span Pages instead.
Follow these steps to determine the amount of space needed to store the data in a hash table.
select tups_per_page * table_dfillpct/100 from iitables where table_name = 'tablename';
total_hash_pages = (num_rows/(tups_per_page)
Note: Because hashing does not guarantee an equal distribution of rows, the actual number of pages required can be greater than calculated above.
Follow these steps to determine the amount of space needed to store the data in an ISAM table:
select tups_per_page * table_dfillpct/100, keys_per_page from iitables where table_name = 'tablename';
data_pages = (num_rows / tups_per_page)
Note: When rows span pages, determine the number of data pages using the calculation in Calculate Space Requirements When Rows Span Pages instead.
index_pages = data_pages / keys_per_page
Note: When rows span pages, use the following calculation instead:
index-pages = num_rows / keys_per_page
total_isam_pages = data_pages + index_pages
if (total_isam_pages < keys_per_page)
total_isam_pages = keys_per_page
Follow these steps to determine the amount of space needed to store the data in a B-tree table:
select tups_per_page * table_dfillpct/100, keys_per_page * table_ifillpct/100, keys_per_leaf * table_lfillpct/100 from iitables where table_name = 'tablename';
leaf_pages = (num_rows/keys_per_leaf)
remainder = modulo (num_rows / (keys_per_leaf)
data_pages = leaf_pages * (keys_per_leaf / tups_per_page)
Note: When rows span pages, determine the number of data pages using the calculation in Calculate Space Requirements When Rows Span Pages instead.
a. leaf_pages = leaf_pages + 1
b. Round the division up to the nearest integer:
data_pages = data_pages + (remainder / tups_per_page)
Note: When rows span pages, Step 5b does not apply.
sprig_pages: The number of index pages that have leaf pages as their next lower level:
a. If leaf_pages <= keys_per_page, then sprig_pages = 0
b. Otherwise, calculate as follows, and round up to the nearest integer:
sprig_pages = (leaf_pages / keys_per_page)
index_pages: The number of index pages that are not sprig pages. This is done iteratively. Do the following if sprig_pages > keys_per_page:
x = sprig_pages
do
{
x = x / keys_per_page
index_pages = index_pages + x
}
while (x > keys_per_page>
total_btree_pages = data_pages + leaf_pages + sprig_pages + index_pages
Follow these steps to determine the amount of space needed to store the data in a table with rows that span pages:
pages_per_row = row_size / max row size
where max_row_size is the maximum row size for the table, as shown in Maximum Row Size Per Page Size.
Round up to the nearest integer.
data_pages = num_rows * pages_per_row
Table rows span pages if the row size is greater than the maximum row size for the table page size, as shown in this table:
Page Size |
Max Row Size |
---|---|
2048 (2 KB) |
2008 bytes |
4096 (4 KB) |
3988 bytes |
8192 (8 KB) |
8084 bytes |
16384 (16 KB) |
16276 bytes |
32768 (32 KB) |
32660 bytes |
65536 (64 KB) |
65428 bytes |
Table size for compressed tables is not possible to determine by an algorithm because the number of fields that can be compressed, and what percentage they can be compressed, differ for every table.
To get any sort of estimate, you must guess the amount by which each record, on the average, can be compressed. Use this estimated record width to determine the size of the table as if it were uncompressed, using the rules set forth above.
The DBMS space management handles used and free page tracking. A table uses a combination of a single free header page (H) and one or more free map pages (M) to track free and used pages.
In VDBA, to view the graphical display of the pages, select a table and select the Pages tab.
Each free map page can track 16,000 pages, recording whether the page is free or used. As tables are allowed to grow past 16,000 pages, there can be more than one free map page in a table.
Free map pages are tracked by the free header page, whose location is recorded in the system catalog entries for the table.
Free header and free map pages are additional pages required for each table page count.
Note: All tables in the database can grow by a minimum of two pages. One free map page is added per 16,000 pages.
Note: For B-tree tables, all empty disassociated data pages and any pages on the old free list are marked as "used." The only way to reclaim this space is to select Shrink B-tree Index in the Modify Table Structure dialog in VDBA, or use the modify table to B-tree statement in SQL. For more information, see the SQL Reference Guide.
VDBA automatically calculates table size based on the number of allocated pages. Using VDBA, select a table and select the Pages tab to view the pages property sheet.
Alternatively, the allocated_pages field in the iitables standard catalog can be used to calculate table size based on the number of allocated pages. You can calculate:
iitables.allocated_pages * PageSize
iitables.allocated_pages – iitables.number_pages