Anda di halaman 1dari 10

ADVANCED TECHNICAL DOCUMENTATION

Computing Database Size


POWERDESIGNER 6.1

December 1997 Copyright 1991-1997 Sybase, Inc. and its subsidiaries. All rights reserved. Printed in the United States of America. Information in this manual may change without notice and does not represent a commitment on the part of Sybase, Inc. and its subsidiaries. The software described in this manual is provided by Powersoft Corporation under a Powersoft License agreement. The software may be used only in accordance with the terms of the agreement. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc. and its subsidiaries. Sybase, Inc. or its subsidiaries claim copyright in this program and documentation as an unpublished work, revisions of which were first licensed on the date indicated in the foregoing notice. Claim of copyright does not imply waiver of other rights of Sybase, Inc. and its subsidiaries. ClearConnect, Column Design, ComponentPack, InfoMaker, ObjectCycle, PowerBuilder, PowerDesigner, Powersoft, S-Designor, SQL SMART, and Sybase are registered trademarks of Sybase, Inc. and its subsidiaries. Adaptive Component Architecture, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Warehouse, AppModeler, DataArchitect, DataExpress, Data Pipeline, DataWindow, dbQueue, ImpactNow, InstaHelp, Jaguar CTS, jConnect for JDBC, MetaWorks, NetImpact, PowerDynamo, Optima++, Power++, PowerAMC, PowerBuilder Foundation Class Library, Power J, PowerScript, PowerSite, Powersoft Portfolio, Powersoft Professional, PowerTips, ProcessAnalyst, Runtime Kit for Unicode, SQL Anywhere, The Model For Client/Server Solutions, The Future Is Wide Open, Translation Toolkit, UNIBOM, Unilib, Uninull, Unisep, Unistring, Viewer, WarehouseArchitect, Watcom, Watcom SQL Server, Web.PB, and Web.SQL are trademarks of Sybase, Inc. or its subsidiaries. Certified PowerBuilder Developer and CPD are service marks of Sybase, Inc. or its subsidiaries. DataWindow is a patented proprietary technology of Sybase, Inc. or its subsidiaries. AccuFonts is a trademark of AccuWare Business Solutions Ltd. All other trademarks are property of their respective owners.

Computing Database Size

About this chapter Contents

This chapter gives technical details on how to compute the suze of a database.
Topic Estimating the size of a table Estimating the size of an index Page 2 7

Estimating the size of a table


The formula for estimating the size of a table includes four steps described below: Estimate the data type size of each column Compute the average size of a record (composed of several columns) Compute the average number of rows per database page Estimate the total number of pages required for the table

Data Type Size


Default Data Type Size
The default data type sizes are the following: If no length is specified
Data type Boolean, char Short integer Integer, long integer, Numeric, Decimal, float, short float, date long float, money time, datetime, timestamp, undefined data type long data type (Text, image ...) Data type size 1 2 4 8 10 255

If a length is specified

Data type money and floating point data types others (char, varchar, ...)

Data type format length / 2 + 1 length

Customization
In the def file, the PhysDttpSize entry customizes the default size of a list of data types. This customization is available only for data types with no length specified. The syntax is:
<Data Type> <New Default Length>

For variable length data types and long data types, it is also possible to define an average length to take into account instead of the maximum length. This average length can be defined in the model for each table column using the Fill property sheet of a table.

Row Length
The formula used for the average size of a record is database dependent. This formula is adapted for the main databases and a default formula is taken for the others:
Database Default Database DB2 (*) Informix Ingres Oracle RedBrick Sql Anywhere Sql Server (*) Row length formula
8 + 5[DttpSize*(1-NullPercent/100)] + NbCol 8 + 5[DttpSize*(1-NullPercent/100)] 4 + 5[DttpSize*(1-NullPercent/100)] 2 + 5[DttpSize*(1-NullPercent/100)] + 2*NbVarCol + NbNullCol 5 + 5[DttpSize*(1-NullPercent/100)] + NbCol + 2*(NbCol with size > 250) 2 + 5[DttpSize*(1-NullPercent/100)] + NbCol / 8 4 + 5[DttpSize*(1-NullPercent/100)] + NbCol / 8 8 + 5[DttpSize*(1-NullPercent/100)] + NbVarCol

(*) For SQL SERVER and DB2 family, the row length does not includes storage of long data (like BLOB, text and image) which are stored in specific storage structures. However, the formula includes the size of the pointer to those data.

DttpSize is the data type size of each column of the record. It has been calculated in the previous step. NullPercent is the percent of null values for each column. It can be defined for non mandatory columns in the "Fill" property sheet of the table. NbCol is the number of columns in the table. NbNullCol is the number of non mandatory columns in the table. NbVarCol is the number of columns with variable length data types in the table.

Number of rows per page


The number of rows per page is estimated as follow:

RowLength has been defined in the previous step. UsablePageSize is defined as:

PageSize is the size of a database page. The value is hard-coded for each database. See below. HeaderSize is the size of the header of a database page. The value is hardcoded for each database. See below. PctFree is the percent of page space to keep free in prevision of row updates. Its value is retrieved from the physical options of the table. Some databases define instead a FillFactor percent (100 - PctFree). If the row length is greater than the UsablePageSize, then we estimate a number of pages per row:

The values of PageSize and HeaderSize are listed for the main databases:
Database Default database DB2 CS DB2 MVS Informix Ingres Oracle RedBrick Sql Anywhere Sql Server Page size 2048 4096 2048 2048 2048 2048 8192 1024 2048 Header size 32 76 32 28 32 32+24*IniTrans 3 11 32

The value of IniTrans is retrieved from the physical options of the table.

The physical options taken into account in this formula are listed for the main databases:
Database Default database DB2 Informix Ingres Oracle RedBrick Sql Anywhere Sql Server fillfactor, max_rows_per_page fillfactor, leaffill, pctfree pctfree, initrans Physical options for storing pctfree, fillfactor

Number of data pages


The number of data pages is then equal to:

NumberOfRowsPerPage is defined in the previous step. NumberOfRowsInTable contains the value of the Number field of the table property sheet.

For some databases, the minimum allocation unit is the extent and can be greater than one database page. In this case, we retrieve from the physical options of the table the sizes of the extents and we adjust the table size to the size of all extents allocated.
Database Default database DB2 Informix Ingres Oracle RedBrick Sql Anywhere Sql Server initial, next, pctincrease extent size, next size Physical options for allocation

At least, for databases managing long data types in separate storages (SQL SERVER and DB2 family), the estimated number of long data pages is:

Estimating the size of an index


The formula for estimating the size of a B-Tree index includes four steps described below: Estimate the data type size of each column of the index Compute the size of an index entry Compute the average number of entries a memory page can store Estimate the total number of pages required for the index

Data type size


 For more details on data type size, see section "Estimating the size of a table".

Index entry length


The formula used for the size of an index entry is database dependent. This formula is adapted for the main databases and a default formula is taken for the others:
Database Default Database DB2 Informix Ingres Oracle RedBrick Sql Anywhere Sql Server System11 Index entry length formula
8 + 5[DttpSize*(1-NullPercent/100)] + NbCol 8 + 5[DttpSize*(1-NullPercent/100)] + NbNullCol 4 + 5[DttpSize*(1-NullPercent/100)] + (5 if unique index) 6 + 5[DttpSize*(1-NullPercent/100)] + 2*NbVarCol + NbNullCol 8 + 5[DttpSize*(1-NullPercent/100)] + NbCol + 2*(NbCol with size > 128) 6 + 5[DttpSize*(1-NullPercent/100)] 4 + 5[DttpSize*(1-NullPercent/100)] + NbCol / 8 8 + 5[VarColDttpSize*(1-NullPercent/100)] + NbCol 11 + 5[VarColDttpSize*(1-NullPercent/100)] + NbCol

DttpSize is the data type size of each column of the index calculated on the previous step.

NullPercent is the percent of null values for each column. It can be defined for non mandatory columns in the Fill property sheet of the table. NbCol is the number of columns in the index. NbNullCol is the number of non mandatory columns in the index. NbVarCol is the number of columns with variable length data types in the index. VarColDttpSize is the data type size of each column of the index with variable length data types.

Number of entries per page


 For more details on the number of entries per page, see "Number of rows per page" in the Estimating the size of a table section.

Number of index pages


The number of index pages is estimated as follow for a non cluster index:

NumberOfRowsInTable contains the value of the Number field of the table property sheet. NumberOfEntriesPerPage has been estimated in the previous step. Each term correspond to an index level. The first term gives the number of leaf index pages. The other terms give the number of non leaf index pages. The last level contains only one page. For cluster indexes, the number of rows in the table should be replaced by the estimated number of data pages of the table (in this case, the leaf index pages are the data pages and are not included in the estimation of the index size):

Anda mungkin juga menyukai