SlideShare a Scribd company logo
1 of 21
Database Sizing
Idea used from: Lake (2014)
Why and When Size?
• Initially to establish the scale of the
required database to help select OS
environment and DBMS
• Establish HDD requirements
• To get a “feel” for the data:
• which tables need special treatment: separate
tablespaces? Partitioning?….
• Generate statistics which help in physical
design
• Continually monitor
Sizing Basics
Bit
“One of the two digits 0 and 1 used in binary
notation. The word comes from Binary digit”
Byte
 “A set of binary digits usually representing
one character, which is treated by the
computer as one unit”
Common Data Types
Type Bytes Range
bit 0 or 1
tinyint 1 0 to 255
smallint 2 -216
to 216
- 1
integer 4 -231
to 231
- 1
decimal(m,n) 8 -1038
to 1038
- 1
datetime 8 depends on DBMS
char(n) , string(n) n Maximum 255
varchar2(n) n Maximum 4000
Oracle Date Data Type
Dates are renowned for causing problems
when transfering data between DBMS
because the method used to store the data
internally differs. For example:
In Oracle the DATE datatype stores the
century, year, month, day, hours, minutes, and
seconds.
Paradox date fields can contain any valid date
from January 1, 9999 BC to December 31, 9999
AD.
Oracle Date Data Type
Example with Oracle:
CREATE TABLE Birthdays_tab (Bname
VARCHAR2(20),Bday DATE) ;
INSERT INTO Birthdays_tab (bname, bday) VALUES
('ANNIE',TO_DATE('13-NOV-92 10:56 A.M.','DD-
MON-YY HH:MI A.M.'));
Oracle uses its own internal format to
store dates. Date data is stored in fixed-
length fields of seven bytes each,
corresponding to century, year, month,
day, hour, minute, and second.
Oracle Varchar2 Data Type
The VARCHAR2 datatype stores variable-length character
strings.
specify a maximum string length (in bytes or characters)
between 1 and 4000 bytes for the VARCHAR2 column.
For each row, Oracle stores each value in the column as a
variable-length field unless a value exceeds the column's
maximum length, in which case Oracle returns an error.
Using VARCHAR2 saves on space used by the table.
For example, storing “PETER” in a column defined as
VARCHAR2(50) will cost only 5 bytes of storage, not 50.
More efficient, but more difficult for sizing!
Oracle LOB Data Types
The LOB datatypes BLOB, CLOB, and BFILE enable you to
store large blocks of unstructured data (such as text,
graphic images, video clips, and sound waveforms) up to 4
gigabytes in size. They provide efficient, random access to
the data.
CLOB is roughly equivalent to a MEMO in Paradox.
You can manipulate and search CLOB fields using special
tools
Again, sizing is difficult as only the space needed is taken
There are lots of other data types, but
these will do for the time being!
Row Sizing
Maximum row size can be determined by
ascertaining the data-types of different
columns of the table and adding together
the respective number of bytes.
Create Table SizeDemo (id Integer, Name
Varchar2(20), Dayte DATE) ;
Max Row Length = 4 + 20 +7 = 31 bytes
Max Row size is a safe estimation, but can
be considerably over estimated.
Oracle Row Sizing (8i onwards)
As an alternative to manual calculation
the average Row Size can be discovered
using the ANALYZE function:
ANALYZE TABLE Member ESTIMATE
STATISTICS;
Then ask for the statistic:
SELECT AVG(NVL(VSIZE(SURNAME),1)) from
member;
Tablespace building blocks
• Data blocks are the finest level of granularity
• A data block is the smallest unit of Input/Output
(I/O) used by the database.
• The block size itself will depend upon several things,
including the OS block size, and is set when the
database is created and is not altered thereafter.
• The data block size should be a multiple of the
operating system's block size.
• For a decision support system (DSS) application, it is
suggested that you choose a large value for the
DB_BLOCK_SIZE. For an OLTP type application, a
lower value (e.g., 2k or 4k) is suggested.
• There is no point in bringing back 32K of data from a
disk if the user only needs 2K!
Data blocks
• Regardless of what the block is being used
to store (it could be part of an Extent in a
table segment, or an index segment, or any
other segment) the data block will be of a
set format.
• The overhead: information about the block
(type, count of entries, timestamp, pointers
to items in the block, etc.). This is often no
more than 100 bytes in size.
• The data section (or Row Data): contains
the rows from the table, or branches of an
index.
• Free Space: the area in a block not yet
taken by row data.
Data blocks
• PCTFREE parameter tells Oracle to stop inserting
data when the free space reduces to 20% of fillable
space
• Free space = Block size-overhead-row data
• Fillable space = Block size-overhead
• The block is now unusable for insertions, and will
remain so until enough rows are deleted to bring
the percentage of the block that is filled with rows
below the PCTUSED parameter setting.
• You do not have to set either parameter: Oracle
defaults to 10% for PCTFREE and 40% for
PCTUSED
• PCTFREE+PCTUSED < 100
create table grades(g_id integer, Grade varchar2(12)) PCTFREE 20 PCTUSED 60;
Block Headers
Vary in size according to information in Block (ie
Index data or Row data)
block header = fixed header + variable
transaction header + table directory + row
directory
Where:
Fixed Header = 57 bytes
Variable transaction = 23 * initrans
Initrans is the number of transaction slots per block. By
default it is 1 for data and 2 for indexes.
Table Directory = 4 bytes
Row directory = 2 bytes for every row in the block
Ref: Oracle Metalink support
Block Space – Worked example block header = fixed header + variable transaction header +
table directory + row directory
 block header = 57 + (23*1) + 4 + 2x = (84 + 2x) bytes, where x =
number of rows in the block (assumes initrans=1)
 available data space = (block size - total block header) -
((block size - total block header) * (PCTFREE/100))
 For example, with PCTFREE = 10 and a block size of 2048, the
total space for new data in a block is:
 available data space = (2048 - (84 + 2x)) - ((2048 - (84 + 2x)) *
(10/100))
 = (1964 - 2x) - ((2048 - 84 - 2x) * (10/100))
 = (1964 - 2x) - (1964 - 2x) * 0.1
 = (1964 - 2x - 196 + 0.2x) bytes
 = (1768 - 1.8x) bytes
Ref: Oracle Metalink support
Sizing: Rows per Block
The next Step is to take your average Row Size
and calculate the average number of rows that
can fit into a database block
average number of rows per block =
floor(available data space / average row size)
Eg, for a average row size of 28 bytes:
average number of rows per block = x = (1768 - 1.8x)/28
bytes
28x = 1768 - 1.8x
29.8x = 1768
x ~ 59 = average number of rows per block
Make sure you round x or the average number of rows per
block DOWN.
Table Sizing
Once you know the number of rows that can fit
inside the available space of a database block,
you can calculate the number of blocks required
to hold the proposed table:
number of blocks for the table = number of
rows / average number of rows per block
Using 10,000 rows for table test:
number of blocks for table test = 10000 rows / 59
rows per block
~ 169 blocks
Index SizingThe method is the same, but there are some
differences in the numbers for Index Blocks:
INITRANS is usually = 2
Fixed Header = 113
So block header size = 113 + (23 * 2) bytes = 159
available data space is still= (block size - block
header size) - ((block size - block header size) *
(PCTFREE/100))
Assuming a block size of 2048 bytes and PCTFREE of 10:
available data space = (2048 bytes - 159 bytes) -
((2048 bytes - 159 bytes) * (10/100)) = 1889 bytes -
188.9 bytes = 1700.1 bytes
Index Sizing cont...
Now find the total average column widths of the
columns used in the index.
Eg: Put an index on the NAME column of SizeDemo.
Assuming average width of 22
Take that into our calculation of bytes per index
entry:
 bytes per entry = entry header + ROWID length + F + V + D
 entry header = 1 byte
 ROWID length = 6 bytes
 F = total length bytes of all columns with 1 byte column
lengths (CHAR, NUMBER, DATE, and ROWID types)
 V = total length bytes of all columns with 3 byte column
lengths (VARCHAR2 and RAW datatypes)
 D = 22 (from above)
Index Sizing cont...
bytes per entry = 1 + 6 + (0 * 1) + (1 * 3) + 22 bytes
= 32 bytes
To calculate the number of blocks and bytes
required for the index, use:
number of blocks for index = 1.1 * ((number of
not null rows * avg. entry size) / avail. data space
The additional 10% added to this result accounts
for branch blocks of the index.
number of blocks for index = 1.1 * ((10000 * 32
bytes) / 1700)
= 208 blocks (rounded up)
Database Sizing
Repeat this exercise for all your major tables and
indexes
80/20 rule applies: don’t waste time on lookups
for example, just make an appropriate, but safe,
guess
Add all the table sizes (in blocks) together and
you have the disk space required
To get this value in bytes, multiply by the
database block size.

More Related Content

What's hot

CS375 Presentation-binary sort.pptx
CS375 Presentation-binary sort.pptxCS375 Presentation-binary sort.pptx
CS375 Presentation-binary sort.pptx
Liyu Ying
 

What's hot (20)

Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
Array c programming
Array c programmingArray c programming
Array c programming
 
Binomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci HeapsBinomial Heaps and Fibonacci Heaps
Binomial Heaps and Fibonacci Heaps
 
DBMS 9 | Extendible Hashing
DBMS 9 | Extendible HashingDBMS 9 | Extendible Hashing
DBMS 9 | Extendible Hashing
 
Tree representation in map reduce world
Tree representation  in map reduce worldTree representation  in map reduce world
Tree representation in map reduce world
 
Week3 binary trees
Week3 binary treesWeek3 binary trees
Week3 binary trees
 
Юра Гуляев. Oracle tables
Юра Гуляев. Oracle tablesЮра Гуляев. Oracle tables
Юра Гуляев. Oracle tables
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
 
R training3
R training3R training3
R training3
 
SQL: Query optimization in practice
SQL: Query optimization in practiceSQL: Query optimization in practice
SQL: Query optimization in practice
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
 
CS375 Presentation-binary sort.pptx
CS375 Presentation-binary sort.pptxCS375 Presentation-binary sort.pptx
CS375 Presentation-binary sort.pptx
 
Moving Data to and From R
Moving Data to and From RMoving Data to and From R
Moving Data to and From R
 
Allocation and free space management
Allocation and free space managementAllocation and free space management
Allocation and free space management
 
MySql
MySqlMySql
MySql
 
Database Performance
Database PerformanceDatabase Performance
Database Performance
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 

Similar to Database Sizing

2011 06-sq lite-forensics
2011 06-sq lite-forensics2011 06-sq lite-forensics
2011 06-sq lite-forensics
viaForensics
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx
MohamedNowfeek1
 

Similar to Database Sizing (20)

MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
SQL
SQLSQL
SQL
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
unit 1 ppt.pptx
unit 1 ppt.pptxunit 1 ppt.pptx
unit 1 ppt.pptx
 
Deep Dive: Amazon DynamoDB
Deep Dive: Amazon DynamoDBDeep Dive: Amazon DynamoDB
Deep Dive: Amazon DynamoDB
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Amazon DynamoDB 深入探討
Amazon DynamoDB 深入探討Amazon DynamoDB 深入探討
Amazon DynamoDB 深入探討
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Maryna Popova "Deep dive AWS Redshift"
Maryna Popova "Deep dive AWS Redshift"Maryna Popova "Deep dive AWS Redshift"
Maryna Popova "Deep dive AWS Redshift"
 
Apache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data modelApache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data model
 
Basic datatypes - deep understanding
Basic datatypes - deep understandingBasic datatypes - deep understanding
Basic datatypes - deep understanding
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Data Warehousing with Amazon Redshift
Data Warehousing with Amazon RedshiftData Warehousing with Amazon Redshift
Data Warehousing with Amazon Redshift
 
2011 06-sq lite-forensics
2011 06-sq lite-forensics2011 06-sq lite-forensics
2011 06-sq lite-forensics
 
Data Collection and Storage
Data Collection and StorageData Collection and Storage
Data Collection and Storage
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx
 
Deep Dive on Amazon DynamoDB
Deep Dive on Amazon DynamoDBDeep Dive on Amazon DynamoDB
Deep Dive on Amazon DynamoDB
 
Indexing
IndexingIndexing
Indexing
 

More from Amin Chowdhury

Tlad better with data - matthew love + charles (2)
Tlad   better with data - matthew love + charles (2)Tlad   better with data - matthew love + charles (2)
Tlad better with data - matthew love + charles (2)
Amin Chowdhury
 
Tlad 2015 presentation amin+charles-final
Tlad 2015 presentation   amin+charles-finalTlad 2015 presentation   amin+charles-final
Tlad 2015 presentation amin+charles-final
Amin Chowdhury
 
090321 - EEHCO Project Plan PSTC- Dhaka
090321 - EEHCO Project Plan PSTC- Dhaka090321 - EEHCO Project Plan PSTC- Dhaka
090321 - EEHCO Project Plan PSTC- Dhaka
Amin Chowdhury
 

More from Amin Chowdhury (8)

OPPORTUNITIES FOR THE USE OF DIGITAL TECHNOLOGY TOOLS
OPPORTUNITIES FOR THE USE OF DIGITAL TECHNOLOGY TOOLSOPPORTUNITIES FOR THE USE OF DIGITAL TECHNOLOGY TOOLS
OPPORTUNITIES FOR THE USE OF DIGITAL TECHNOLOGY TOOLS
 
Tlad better with data - matthew love + charles (2)
Tlad   better with data - matthew love + charles (2)Tlad   better with data - matthew love + charles (2)
Tlad better with data - matthew love + charles (2)
 
Tlad 2015 presentation amin+charles-final
Tlad 2015 presentation   amin+charles-finalTlad 2015 presentation   amin+charles-final
Tlad 2015 presentation amin+charles-final
 
Database Project management
Database Project managementDatabase Project management
Database Project management
 
Database Industry perspective
Database Industry perspectiveDatabase Industry perspective
Database Industry perspective
 
090321 - EEHCO Project Plan PSTC- Dhaka
090321 - EEHCO Project Plan PSTC- Dhaka090321 - EEHCO Project Plan PSTC- Dhaka
090321 - EEHCO Project Plan PSTC- Dhaka
 
E-commerce Project Development
E-commerce Project DevelopmentE-commerce Project Development
E-commerce Project Development
 
Data Quality: A Raising Data Warehousing Concern
Data Quality: A Raising Data Warehousing ConcernData Quality: A Raising Data Warehousing Concern
Data Quality: A Raising Data Warehousing Concern
 

Recently uploaded

Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 

Recently uploaded (20)

Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 

Database Sizing

  • 1. Database Sizing Idea used from: Lake (2014)
  • 2. Why and When Size? • Initially to establish the scale of the required database to help select OS environment and DBMS • Establish HDD requirements • To get a “feel” for the data: • which tables need special treatment: separate tablespaces? Partitioning?…. • Generate statistics which help in physical design • Continually monitor
  • 3. Sizing Basics Bit “One of the two digits 0 and 1 used in binary notation. The word comes from Binary digit” Byte  “A set of binary digits usually representing one character, which is treated by the computer as one unit”
  • 4. Common Data Types Type Bytes Range bit 0 or 1 tinyint 1 0 to 255 smallint 2 -216 to 216 - 1 integer 4 -231 to 231 - 1 decimal(m,n) 8 -1038 to 1038 - 1 datetime 8 depends on DBMS char(n) , string(n) n Maximum 255 varchar2(n) n Maximum 4000
  • 5. Oracle Date Data Type Dates are renowned for causing problems when transfering data between DBMS because the method used to store the data internally differs. For example: In Oracle the DATE datatype stores the century, year, month, day, hours, minutes, and seconds. Paradox date fields can contain any valid date from January 1, 9999 BC to December 31, 9999 AD.
  • 6. Oracle Date Data Type Example with Oracle: CREATE TABLE Birthdays_tab (Bname VARCHAR2(20),Bday DATE) ; INSERT INTO Birthdays_tab (bname, bday) VALUES ('ANNIE',TO_DATE('13-NOV-92 10:56 A.M.','DD- MON-YY HH:MI A.M.')); Oracle uses its own internal format to store dates. Date data is stored in fixed- length fields of seven bytes each, corresponding to century, year, month, day, hour, minute, and second.
  • 7. Oracle Varchar2 Data Type The VARCHAR2 datatype stores variable-length character strings. specify a maximum string length (in bytes or characters) between 1 and 4000 bytes for the VARCHAR2 column. For each row, Oracle stores each value in the column as a variable-length field unless a value exceeds the column's maximum length, in which case Oracle returns an error. Using VARCHAR2 saves on space used by the table. For example, storing “PETER” in a column defined as VARCHAR2(50) will cost only 5 bytes of storage, not 50. More efficient, but more difficult for sizing!
  • 8. Oracle LOB Data Types The LOB datatypes BLOB, CLOB, and BFILE enable you to store large blocks of unstructured data (such as text, graphic images, video clips, and sound waveforms) up to 4 gigabytes in size. They provide efficient, random access to the data. CLOB is roughly equivalent to a MEMO in Paradox. You can manipulate and search CLOB fields using special tools Again, sizing is difficult as only the space needed is taken There are lots of other data types, but these will do for the time being!
  • 9. Row Sizing Maximum row size can be determined by ascertaining the data-types of different columns of the table and adding together the respective number of bytes. Create Table SizeDemo (id Integer, Name Varchar2(20), Dayte DATE) ; Max Row Length = 4 + 20 +7 = 31 bytes Max Row size is a safe estimation, but can be considerably over estimated.
  • 10. Oracle Row Sizing (8i onwards) As an alternative to manual calculation the average Row Size can be discovered using the ANALYZE function: ANALYZE TABLE Member ESTIMATE STATISTICS; Then ask for the statistic: SELECT AVG(NVL(VSIZE(SURNAME),1)) from member;
  • 11. Tablespace building blocks • Data blocks are the finest level of granularity • A data block is the smallest unit of Input/Output (I/O) used by the database. • The block size itself will depend upon several things, including the OS block size, and is set when the database is created and is not altered thereafter. • The data block size should be a multiple of the operating system's block size. • For a decision support system (DSS) application, it is suggested that you choose a large value for the DB_BLOCK_SIZE. For an OLTP type application, a lower value (e.g., 2k or 4k) is suggested. • There is no point in bringing back 32K of data from a disk if the user only needs 2K!
  • 12. Data blocks • Regardless of what the block is being used to store (it could be part of an Extent in a table segment, or an index segment, or any other segment) the data block will be of a set format. • The overhead: information about the block (type, count of entries, timestamp, pointers to items in the block, etc.). This is often no more than 100 bytes in size. • The data section (or Row Data): contains the rows from the table, or branches of an index. • Free Space: the area in a block not yet taken by row data.
  • 13. Data blocks • PCTFREE parameter tells Oracle to stop inserting data when the free space reduces to 20% of fillable space • Free space = Block size-overhead-row data • Fillable space = Block size-overhead • The block is now unusable for insertions, and will remain so until enough rows are deleted to bring the percentage of the block that is filled with rows below the PCTUSED parameter setting. • You do not have to set either parameter: Oracle defaults to 10% for PCTFREE and 40% for PCTUSED • PCTFREE+PCTUSED < 100 create table grades(g_id integer, Grade varchar2(12)) PCTFREE 20 PCTUSED 60;
  • 14. Block Headers Vary in size according to information in Block (ie Index data or Row data) block header = fixed header + variable transaction header + table directory + row directory Where: Fixed Header = 57 bytes Variable transaction = 23 * initrans Initrans is the number of transaction slots per block. By default it is 1 for data and 2 for indexes. Table Directory = 4 bytes Row directory = 2 bytes for every row in the block Ref: Oracle Metalink support
  • 15. Block Space – Worked example block header = fixed header + variable transaction header + table directory + row directory  block header = 57 + (23*1) + 4 + 2x = (84 + 2x) bytes, where x = number of rows in the block (assumes initrans=1)  available data space = (block size - total block header) - ((block size - total block header) * (PCTFREE/100))  For example, with PCTFREE = 10 and a block size of 2048, the total space for new data in a block is:  available data space = (2048 - (84 + 2x)) - ((2048 - (84 + 2x)) * (10/100))  = (1964 - 2x) - ((2048 - 84 - 2x) * (10/100))  = (1964 - 2x) - (1964 - 2x) * 0.1  = (1964 - 2x - 196 + 0.2x) bytes  = (1768 - 1.8x) bytes Ref: Oracle Metalink support
  • 16. Sizing: Rows per Block The next Step is to take your average Row Size and calculate the average number of rows that can fit into a database block average number of rows per block = floor(available data space / average row size) Eg, for a average row size of 28 bytes: average number of rows per block = x = (1768 - 1.8x)/28 bytes 28x = 1768 - 1.8x 29.8x = 1768 x ~ 59 = average number of rows per block Make sure you round x or the average number of rows per block DOWN.
  • 17. Table Sizing Once you know the number of rows that can fit inside the available space of a database block, you can calculate the number of blocks required to hold the proposed table: number of blocks for the table = number of rows / average number of rows per block Using 10,000 rows for table test: number of blocks for table test = 10000 rows / 59 rows per block ~ 169 blocks
  • 18. Index SizingThe method is the same, but there are some differences in the numbers for Index Blocks: INITRANS is usually = 2 Fixed Header = 113 So block header size = 113 + (23 * 2) bytes = 159 available data space is still= (block size - block header size) - ((block size - block header size) * (PCTFREE/100)) Assuming a block size of 2048 bytes and PCTFREE of 10: available data space = (2048 bytes - 159 bytes) - ((2048 bytes - 159 bytes) * (10/100)) = 1889 bytes - 188.9 bytes = 1700.1 bytes
  • 19. Index Sizing cont... Now find the total average column widths of the columns used in the index. Eg: Put an index on the NAME column of SizeDemo. Assuming average width of 22 Take that into our calculation of bytes per index entry:  bytes per entry = entry header + ROWID length + F + V + D  entry header = 1 byte  ROWID length = 6 bytes  F = total length bytes of all columns with 1 byte column lengths (CHAR, NUMBER, DATE, and ROWID types)  V = total length bytes of all columns with 3 byte column lengths (VARCHAR2 and RAW datatypes)  D = 22 (from above)
  • 20. Index Sizing cont... bytes per entry = 1 + 6 + (0 * 1) + (1 * 3) + 22 bytes = 32 bytes To calculate the number of blocks and bytes required for the index, use: number of blocks for index = 1.1 * ((number of not null rows * avg. entry size) / avail. data space The additional 10% added to this result accounts for branch blocks of the index. number of blocks for index = 1.1 * ((10000 * 32 bytes) / 1700) = 208 blocks (rounded up)
  • 21. Database Sizing Repeat this exercise for all your major tables and indexes 80/20 rule applies: don’t waste time on lookups for example, just make an appropriate, but safe, guess Add all the table sizes (in blocks) together and you have the disk space required To get this value in bytes, multiply by the database block size.