SQL Server Physical Architecture
SQL Server Physical Architecture
SQL Server Physical Architecture
Training Division
New Delhi
Pages
? The fundamental unit of data
storage in Microsoft SQL
Server is the page.
? Contains on entry for each row on the page and each entry
records how far the first byte of the row is from the start of
the page.
Page address
Page address
Log Data
For each page, the PFS has a bitmap recording whether the
page is
? empty
? 1-50% full,
? 51-80% full,
? 81-95% full,
? or 96-100% full.
Global Allocation Map pages
Free 1 0
Uniform 0 0
• Maximum size of a • 4 TB
log file
SQL Server 7.0 databases have three types of files:
C:\MSSQL7\data\training_Data.MDF A
C:\MSSQL7\data\training_Log.LDF B
? Each time the file fills, it increases its size by the growth increment.
? If there are multiple files in a filegroup, they do not autogrow until all the files
are full.
? If a maximum size is not specified, the file can continue to grow until it has
used all available space on the disk.
? The user can let the files autogrow as needed to lessen the administrative
burden of monitoring the amount of free space in the database and allocating
additional space manually.
Points to remember :
• If the database must never be allowed to grow beyond its
initial size,then set the maximum growth size of the database
to zero.
• This will prevent the database files from growing. If the
database files fill with data, no more data is added until more
data files are added to the database or existing files are
expanded.
Fragmentation of Files
• Allowing files to grow automatically can cause fragmentation
of those files if a large number of files share the same disk.
• Therefore, it is recommended that files or filegroups be
created on as many different available local physical disks as
possible.
• Place objects that compete heavily for space in different
filegroups.
Disk Management Techniques
? Shrinking activity occurs in the background and does not affect any
user activity within the database.
Shrinks the size of the data files in the specified database.
DBCC SHRINKDATABASE
( database_name [, target_percent]
[, {NOTRUNCATE | TRUNCATEONLY}]
)
Shrinking size of database file
Shrinks the size of the specified data file or log file for the
related database.
DBCC SHRINKFILE
{file_name | file_id }
{ [, target_size]
| [, {EMPTYFILE | NOTRUNCATE | TRUNCATEONLY}]
}
)
Database filegroups
A database comprises of :
? A primary filegroup and
? Any user-defined filegroups.
? Default filegroups.
Default filegroup
They contains the pages for all tables and indexes that do
not have a filegroup specified when they are created. In
each database, only one filegroup at a time can be the
default filegroup. If no default filegroup was specified, it
defaults to the primary filegroup.
Some important facts about file groups:
? No file can be a member of more than one
filegroup.
? Log files are never a part of a filegroup.
USE Trg
CREATE TABLE TrgTable
(par_id int PRIMARY KEY,
par_nm char(8) )
ON Trg_FG1
GO
Indexes
Indexes can be of two types:
1. Clustered Index :
?Data rows are sorted and stored in the table based on their key values.
?There can only be one clustered index per table because the data rows
themselves can only be sorted in one order.
?The data rows form the lowest level of the clustered index.
2. Non Clustered Index :
•The lowest rows contain the nonclustered index key values and each key
value entry has pointers to the data rows containing the key value.
•The data rows are not stored in order based on the nonclustered key.
Two types of tables :
1.Clustered tables
2. Heaps
Are tables that have no clustered index.
The data rows are not stored in any particular order, and
there is no particular order to the sequence of the data
pages. The data pages are not linked in a linked list.
Maximum Capacity Specifications
This table specifies the maximum sizes and numbers of various objects
defined in Microsoft SQL Server databases or referenced in Transact-SQL
statements.
* Database objects include all tables, views, stored procedures, extended stored
procedures, triggers, rules, defaults, and constraints. The sum of the number of
all these objects in a database cannot exceed 2,147,483,647.