SlideShare a Scribd company logo
SQL Server
Database
Structures
PRESENTERINFO
1982 I started working with computers
1988 I started my professional career in computers industry
1996 I started working with SQL Server 6.0
1998 I earned my first certification at Microsoft as
Microsoft Certified Solution Developer (3rd in Greece)
1999 I started my career as Microsoft Certified Trainer (MCT) with more than
30.000 hours of training until now!
2010 I became for first time Microsoft MVP on Data Platform
I created the SQL School Greece www.sqlschool.gr
2012 I became MCT Regional Lead by Microsoft Learning Program.
2013 I was certified as MCSE : Data Platform
I was certified as MCSE : Business Intelligence
2016 I was certified as MCSE: Data Management & Analytics
2017 Certified as MCSA : Machine Learning
Recertified as MCSE: Data Management & Analytics
Antonios
Chatzipavlis
Data Solutions
Consultant & Trainer
MVP on Data Platform
MCT, MCSE, MCITP, MCPD, MCSD, MCDBA,
MCSA, MCTS, MCAD, MCP, OCA, ITIL-F
Μια πηγή ενημέρωσης για την Microsoft Data Platform
προς τους Έλληνες IT Professionals, DBAs, Developers,
Information Workers αλλά και απλούς χομπίστες που
απλά τους αρέσει ο SQL Server.
Help line : help@sqlschool.gr
• Articles about SQL Server
• SQL Server News
• SQL Nights
• Webcasts
• Downloads
• Resources
What we are doing here Follow us in socials
fb/sqlschoolgr
fb/groups/sqlschool
@antoniosch
@sqlschool
yt/c/SqlschoolGr
SQL School Greece group
SELECT KNOWLEDGE
FROM SQL SERVER
Connect with PASS
Sign up for a free membership today at:
pass.org
is the PASS Local Group in Greece
PASS VIRTUAL CHAPTERS
SPONSORS
PRESENTATIONCONTENT
• Database Structure Internals
• Data File Internals
• tempdb Internals
DATABASE
STRUCTURE
INTERNALS
• 32,767 Databases per instance
• 524,767 TB is the max size per
database
• 16 TB is the max size for each data file
• 2 TB is the max size for each log file
• 32,767 files per database
• 32,767 filegroups per database
• 64 KB is the size of each Extent
- 8 pages X 8 KB per page
• 8 KB is the size of each Page
DATABASE COMPONENTS
Database
File Group
(one or more)
Data File
(one or more)
Extent
(mixed or uniform)
Pages
(8 KB each)
File groups
• Logical grouping of data files
• Can bring administration and
performance benefits
• FILESTREAM has its own file group
FILEGROUPS AND DATABASE FILES
Database Files
• Data Files
- At least one per database
- Multiple files can:
- improve performance,
- aid maintainability
- circumvent operating system file size
limitations
• Transaction Log Files
- Usually only one per database
- No performance advantage from
multiple files
EXTENTS
Comprises eight physically continuous pages
Mixed
shared between
different
database objects
Uniform
owned by a
single
database object
PAGE STRUCTURE AND PAGE TYPES
Page Types
• Data (1)
• Index (2)
• Text (3 and 4)
• Boot (13)
• File Header (15)
• PFS (11)
• GAM (8)
• SGAM (9)
• IAM (10)
• DIFF_MAP (16)
• ML_MAP (17)
PAGE HEADER
pageID The file number and page number of this page in the database Metadata: ObjectId The ID of the object to which this page belongs
slotCnt The total number of slots (rows) used on this page Metadata: PartitionId The ID of the partition that this page is part of
Type Page Type Metadata: AllocUnitId The ID of the allocation unit that contains this page
LSN The LSN corresponding to the last log entry that changed this page freeData The byte offset of the first free space on this page
nextPage The file number and page number of the next page if this page is in
a page chain
Pminlen The number of bytes in fixed-length portion of rows
prevPage The file number and page number of the previous page if this page
is in a page chain
freeCnt The number of free bytes on the page
Level The level of this page in an index (always 0 for leaf pages) indexId The index ID of this page (always 0 for data pages)
• Data rows for in-row data
- The maximum size of a single data row is 8,060 bytes of in-row data.
- Rows can also have row-overflow and LOB data stored on separate pages.
- The number of rows stored on a given page varies depending on the table
structure and on the data being stored.
- A table with all fixed-length columns always can store the same number of
rows per page
- Variable-length rows can store as many rows as will fit based on the actual
length of the data entered.
- Keeping the row length shorter allows more rows to fit on a page, thus
reducing I/O and increasing the likelihood that needed data can stay in cache.
• Row offset array
- The row offset array is a block of 2-byte entries
- Each indicating the offset on the page at which the corresponding data row
begins.
- The row offset array indicates the logical order of rows on a page.
- For example, if a table has a clustered index, SQL Server stores the rows in the order of the
clustered index key.
- This doesn’t mean the rows are physically stored on the page in the order of
the clustered index key.
- Rather, slot 0 in the offset array refers to the first row in the clustered index key order, slot 1
refers to the second row, and so forth
DATA ROWS AND ROW OFFSET ARRAY
• Status Bits A
- Bit 0. This indicates special versioning information. In SQL Server 2012, this is always 0.
- Bits 1 through 3. Taken as a 3-bit value,
- 0(000) indicates a primary record,
- 1 (001) indicates a forwarded record,
- 2 (010) indicates a forwarding stub,
- 3 (011) indicates an index record,
- 4 (100) indicates a BLOB fragment or row-overflow data
- 5(101) indicates a ghost index record
- 6(110) indicates a ghost data record,
- 7(111) indicates a ghost version record.
- Bit 4. This indicates that a NULL bitmap exists. In SQL Server 2012, a NULL bitmap is always
present, even if no NULLs are allowed in any column.
- Bit 5. This indicates that variable-length columns exist in the row.
- Bit 6. This indicates that the row contains versioning information.
- Bit 7. This isn’t used in SQL Server 2012.
• Status Bits B
- The only bit used in the Status Bits B field indicates that the record is a ghost forwarded record.
RECORD STRUCTURE AND RECORD TYPES
• File Header Page (FH)
• Page Free Space (PFS)
• Global Allocation Map (GAM)
• Shared Global Allocation Map (SGAM)
• Differential Change Map (DCM)
• Bulk Change Map
• Boot Page
• Index Allocation Map (IAM)
ALLOCATION BITMAPS AND SPECIAL PAGES
• Page allocation
•The process of allocating new pages to an object
• Allocation units
•IN_ROW_DATA
•LOB_DATA
•ROW_OVERFLOW_DATA
• Page allocations can be analysed using DBCC page
PAGE ALLOCATION AND ALLOCATION UNITS
DBCC PAGE
DBCC PAGE ({dbid | dbname}, filenum, pagenum[, printopt])
DBCC TRACEON(3604);
GO
DBCC PAGE (AdventureWorks2012, 1, 266, 1);
ANALYZING
DATABASE STRUCTURES
DATA FILE
INTERNALS
VOLUME CONFIGURATION BEST PRACTICES
Volume
RAID 10 for
transaction log
files
RAID 10 or RAID
5 for database
data files
Store data and
transaction log
files on physically
separate volumes
Defragment disks
frequently
Size data and
transaction log
files to avoid
auto growth
NUMBER OF DATA FILES AND PL ACEMENT
For most databases
a single data file is
sufficient:
To improve
performance:
• Logical I/O
- pages read from cache
• Physical I/O
- pages read from disk
• You can view physical and logical
I/O stats using
- the DMV sys.dm_exec_query_stats
or
- by using the Transact-SQL
command SET STATISTICS IO ON
before issuing a query.
- SET STATISTICS IO ON will only return
statistics for queries in the current
session.
PHYSICAL I/O VS. LOGICAL I/O
• Buffer cache hit ratio
- percentage of pages read from cache
without having to be read from disk
- calculated by the formula ((logical
reads–physical reads)/logical reads) *
100.
- a SQL Server instance that is
performing well will have a buffer
cache hit ratio close to 100.
- The buffer cache hit ratio can be
improved by making more memory
available to SQL Server.
ALLOCATIONS WITHIN DATA FILES
Allocation is simple
in a file group that
has a single file
In a multifile group,
SQL Server uses:
• Round robin allocation
• Proportional fill
INSTANT FILE INITIALIZATION
Improves
performance by
skipping zeroing
of data pages on
file creation and
growth
Best practice is
to enable
following
assessment of
security risk
Disabled by
default: security
risk
Auto Grow
• Automatically expands a file
when space is low
• Manually manage file size for
better performance
• Auto grow best practices:
- Leave enabled to avoid
downtime in case file size limit is
reached
- Set to a fixed rather than a
percentage
AUTO GROW AND AUTO SHRINK
Auto Shrink
• Shrinks data file automatically
to release disk space
• Use with caution as:
- Auto shrink causes index
fragmentation
- It’s uncontrollable and affects
performance
- It can lead to growth-shrink cycle
severely affecting performance
DATA FILE SHRINKING
Shrink
• Causes index
fragmentation
• Resource intensive
• Degrades
performance
Best used for
• Emptying a file
before removing it
• Changing a file or
file group to read
only
• Reclaiming free
space following
large delete
operation
Alternative
• Move all indexes
to a new file group
• Move heaps with
shrink. Heaps are
not fragmented
with shrink
• Remove old file
group
Database file configuration
• SSMS database properties
• sp_helpfile and
sp_helpfilegroup
• sys.database_files and
sys.filegroups
• sys.master_files
• sys.dm_db_file_space_usage
MONITORING DATABASE FILES
Database file activity
•SSMS Activity Monitor – Data File
I/O
•Wait statistics –
PAGEIOLATCH_*, WRITELOG
•sys.dm_io_virtual_file_stats
ALLOCATIONS
WITHIN DATA FILES
TEMPDB
INTERNALS
TEMPDB USAGE
tempdb
tempdb Stores:
• Internal objects
• Version store
• Some user objects
Recreated at
startup
Must not be
allowed to run
out of space
Should be
actively
SQLServer Database Structures
VERSION STORE INTERNALS
Stores all version
records from all
databases
New allocation unit
created every minute
Cleanup happens every
minute
Nonlogged operation
Version Store
Configuration
• Enable instant file initialization
• Size for expected workload
• Isolate tempdb data files
• Use multiple data files
• Enable auto growth as a
contingency
TEMPDB CONFIGURATION
Prohibited operations
• Backup and restore
• Add file groups
• Change collation
• Set offline or read only
tempdb size can be monitored using the sys.dm_db_file_space_usage DMV
MONITORING
TEMPDB USAGE
Ask your
Questions
EVALUATIONS
http://bit.ly/2xUr3XP
EVENT EVALUATION LINK SESSIONS EVALUATION LINK
http://bit.ly/2snEVoq
Thank you
SELECT KNOWLEDGE FROM SQL SERVER
Copyright © 2018 SQLschool.gr. All right reserved.
PRESENTER MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION
Ad

Recommended

MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 
Azure Synapse 101 Webinar Presentation
Azure Synapse 101 Webinar Presentation
Matthew W. Bowers
 
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Databricks
 
Modern Data Warehousing with the Microsoft Analytics Platform System
Modern Data Warehousing with the Microsoft Analytics Platform System
James Serra
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
Enkitec
 
Databricks for Dummies
Databricks for Dummies
Rodney Joyce
 
Azure Data Factory Data Flow
Azure Data Factory Data Flow
Mark Kromer
 
Parquet performance tuning: the missing guide
Parquet performance tuning: the missing guide
Ryan Blue
 
Introduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse Architecture
Databricks
 
Introduction to Azure Data Lake
Introduction to Azure Data Lake
Antonios Chatzipavlis
 
Unified Big Data Processing with Apache Spark (QCON 2014)
Unified Big Data Processing with Apache Spark (QCON 2014)
Databricks
 
Microsoft Azure Databricks
Microsoft Azure Databricks
Sascha Dittmann
 
Apache Spark Overview
Apache Spark Overview
Vadim Y. Bichutskiy
 
Sql Server Performance Tuning
Sql Server Performance Tuning
Bala Subra
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL Developer
Jeff Smith
 
WebLogic 12c & WebLogic Mgmt Pack
WebLogic 12c & WebLogic Mgmt Pack
DLT Solutions
 
Database performance tuning and query optimization
Database performance tuning and query optimization
Dhani Ahmad
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
Tanel Poder
 
Overview SQL Server 2019
Overview SQL Server 2019
Juan Fabian
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
Yogiji Creations
 
Always on in sql server 2017
Always on in sql server 2017
Gianluca Hotz
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
Kyle Hailey
 
Introduction to Azure Databricks
Introduction to Azure Databricks
James Serra
 
adb.pdf
adb.pdf
AdityaMehta724216
 
Technical Deck Delta Live Tables.pdf
Technical Deck Delta Live Tables.pdf
Ilham31574
 
Data Guard Architecture & Setup
Data Guard Architecture & Setup
Satishbabu Gunukula
 
Azure AD connect- Deep Dive Webinar PPT
Azure AD connect- Deep Dive Webinar PPT
Radhakrishnan Govindan
 
ETL in the Cloud With Microsoft Azure
ETL in the Cloud With Microsoft Azure
Mark Kromer
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Michael Rys
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 

More Related Content

What's hot (20)

Introduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse Architecture
Databricks
 
Introduction to Azure Data Lake
Introduction to Azure Data Lake
Antonios Chatzipavlis
 
Unified Big Data Processing with Apache Spark (QCON 2014)
Unified Big Data Processing with Apache Spark (QCON 2014)
Databricks
 
Microsoft Azure Databricks
Microsoft Azure Databricks
Sascha Dittmann
 
Apache Spark Overview
Apache Spark Overview
Vadim Y. Bichutskiy
 
Sql Server Performance Tuning
Sql Server Performance Tuning
Bala Subra
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL Developer
Jeff Smith
 
WebLogic 12c & WebLogic Mgmt Pack
WebLogic 12c & WebLogic Mgmt Pack
DLT Solutions
 
Database performance tuning and query optimization
Database performance tuning and query optimization
Dhani Ahmad
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
Tanel Poder
 
Overview SQL Server 2019
Overview SQL Server 2019
Juan Fabian
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
Yogiji Creations
 
Always on in sql server 2017
Always on in sql server 2017
Gianluca Hotz
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
Kyle Hailey
 
Introduction to Azure Databricks
Introduction to Azure Databricks
James Serra
 
adb.pdf
adb.pdf
AdityaMehta724216
 
Technical Deck Delta Live Tables.pdf
Technical Deck Delta Live Tables.pdf
Ilham31574
 
Data Guard Architecture & Setup
Data Guard Architecture & Setup
Satishbabu Gunukula
 
Azure AD connect- Deep Dive Webinar PPT
Azure AD connect- Deep Dive Webinar PPT
Radhakrishnan Govindan
 
ETL in the Cloud With Microsoft Azure
ETL in the Cloud With Microsoft Azure
Mark Kromer
 
Introduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse Architecture
Databricks
 
Unified Big Data Processing with Apache Spark (QCON 2014)
Unified Big Data Processing with Apache Spark (QCON 2014)
Databricks
 
Microsoft Azure Databricks
Microsoft Azure Databricks
Sascha Dittmann
 
Sql Server Performance Tuning
Sql Server Performance Tuning
Bala Subra
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL Developer
Jeff Smith
 
WebLogic 12c & WebLogic Mgmt Pack
WebLogic 12c & WebLogic Mgmt Pack
DLT Solutions
 
Database performance tuning and query optimization
Database performance tuning and query optimization
Dhani Ahmad
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
Tanel Poder
 
Overview SQL Server 2019
Overview SQL Server 2019
Juan Fabian
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
Yogiji Creations
 
Always on in sql server 2017
Always on in sql server 2017
Gianluca Hotz
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
Kyle Hailey
 
Introduction to Azure Databricks
Introduction to Azure Databricks
James Serra
 
Technical Deck Delta Live Tables.pdf
Technical Deck Delta Live Tables.pdf
Ilham31574
 
Azure AD connect- Deep Dive Webinar PPT
Azure AD connect- Deep Dive Webinar PPT
Radhakrishnan Govindan
 
ETL in the Cloud With Microsoft Azure
ETL in the Cloud With Microsoft Azure
Mark Kromer
 

Similar to SQLServer Database Structures (20)

Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Michael Rys
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Charley Hanania
 
Implementing the Databese Server session 02
Implementing the Databese Server session 02
Guillermo Julca
 
Best storage engine for MySQL
Best storage engine for MySQL
tomflemingh2
 
Sql Bits 2020 - Designing Performant and Scalable Data Lakes using Azure Data...
Sql Bits 2020 - Designing Performant and Scalable Data Lakes using Azure Data...
Rukmani Gopalan
 
MySpace Data Architecture June 2009
MySpace Data Architecture June 2009
Mark Ginnebaugh
 
Prague data management meetup 2018-03-27
Prague data management meetup 2018-03-27
Martin Bém
 
VLDB Administration Strategies
VLDB Administration Strategies
Murilo Miranda
 
Optimize SQL server performance for SharePoint
Optimize SQL server performance for SharePoint
serge luca
 
Mysql For Developers
Mysql For Developers
Carol McDonald
 
SharePoint 2010 database maintenance
SharePoint 2010 database maintenance
Matt Ranlett
 
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum
 
Dipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAs
Bob Pusateri
 
In-memory ColumnStore Index
In-memory ColumnStore Index
SolidQ
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
John Martin
 
What's new in SQL Server 2016
What's new in SQL Server 2016
James Serra
 
ora_sothea
ora_sothea
thysothea
 
Deep Dive into DynamoDB
Deep Dive into DynamoDB
AWS Germany
 
How SQL Server 2016 SP1 Changes the Game
How SQL Server 2016 SP1 Changes the Game
PARIKSHIT SAVJANI
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Michael Rys
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Charley Hanania
 
Implementing the Databese Server session 02
Implementing the Databese Server session 02
Guillermo Julca
 
Best storage engine for MySQL
Best storage engine for MySQL
tomflemingh2
 
Sql Bits 2020 - Designing Performant and Scalable Data Lakes using Azure Data...
Sql Bits 2020 - Designing Performant and Scalable Data Lakes using Azure Data...
Rukmani Gopalan
 
MySpace Data Architecture June 2009
MySpace Data Architecture June 2009
Mark Ginnebaugh
 
Prague data management meetup 2018-03-27
Prague data management meetup 2018-03-27
Martin Bém
 
VLDB Administration Strategies
VLDB Administration Strategies
Murilo Miranda
 
Optimize SQL server performance for SharePoint
Optimize SQL server performance for SharePoint
serge luca
 
SharePoint 2010 database maintenance
SharePoint 2010 database maintenance
Matt Ranlett
 
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum - IOUG Collaborate 2013 - An Insight into Space Realization on ODA...
Maaz Anjum
 
Dipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAs
Bob Pusateri
 
In-memory ColumnStore Index
In-memory ColumnStore Index
SolidQ
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
John Martin
 
What's new in SQL Server 2016
What's new in SQL Server 2016
James Serra
 
Deep Dive into DynamoDB
Deep Dive into DynamoDB
AWS Germany
 
How SQL Server 2016 SP1 Changes the Game
How SQL Server 2016 SP1 Changes the Game
PARIKSHIT SAVJANI
 
Ad

More from Antonios Chatzipavlis (20)

Data virtualization using polybase
Data virtualization using polybase
Antonios Chatzipavlis
 
SQL server Backup Restore Revealed
SQL server Backup Restore Revealed
Antonios Chatzipavlis
 
Migrate SQL Workloads to Azure
Migrate SQL Workloads to Azure
Antonios Chatzipavlis
 
Machine Learning in SQL Server 2019
Machine Learning in SQL Server 2019
Antonios Chatzipavlis
 
Workload Management in SQL Server 2019
Workload Management in SQL Server 2019
Antonios Chatzipavlis
 
Loading Data into Azure SQL DW (Synapse Analytics)
Loading Data into Azure SQL DW (Synapse Analytics)
Antonios Chatzipavlis
 
Introduction to DAX Language
Introduction to DAX Language
Antonios Chatzipavlis
 
Building diagnostic queries using DMVs and DMFs
Building diagnostic queries using DMVs and DMFs
Antonios Chatzipavlis
 
Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns
Antonios Chatzipavlis
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
Antonios Chatzipavlis
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
Sqlschool 2017 recap - 2018 plans
Sqlschool 2017 recap - 2018 plans
Antonios Chatzipavlis
 
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Antonios Chatzipavlis
 
Microsoft SQL Family and GDPR
Microsoft SQL Family and GDPR
Antonios Chatzipavlis
 
Statistics and Indexes Internals
Statistics and Indexes Internals
Antonios Chatzipavlis
 
Azure SQL Data Warehouse
Azure SQL Data Warehouse
Antonios Chatzipavlis
 
Introduction to azure document db
Introduction to azure document db
Antonios Chatzipavlis
 
Introduction to Machine Learning on Azure
Introduction to Machine Learning on Azure
Antonios Chatzipavlis
 
Introduction to sql database on azure
Introduction to sql database on azure
Antonios Chatzipavlis
 
Workload Management in SQL Server 2019
Workload Management in SQL Server 2019
Antonios Chatzipavlis
 
Loading Data into Azure SQL DW (Synapse Analytics)
Loading Data into Azure SQL DW (Synapse Analytics)
Antonios Chatzipavlis
 
Building diagnostic queries using DMVs and DMFs
Building diagnostic queries using DMVs and DMFs
Antonios Chatzipavlis
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
Antonios Chatzipavlis
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
Antonios Chatzipavlis
 
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Antonios Chatzipavlis
 
Introduction to Machine Learning on Azure
Introduction to Machine Learning on Azure
Antonios Chatzipavlis
 
Introduction to sql database on azure
Introduction to sql database on azure
Antonios Chatzipavlis
 
Ad

Recently uploaded (20)

Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 

SQLServer Database Structures

  • 2. PRESENTERINFO 1982 I started working with computers 1988 I started my professional career in computers industry 1996 I started working with SQL Server 6.0 1998 I earned my first certification at Microsoft as Microsoft Certified Solution Developer (3rd in Greece) 1999 I started my career as Microsoft Certified Trainer (MCT) with more than 30.000 hours of training until now! 2010 I became for first time Microsoft MVP on Data Platform I created the SQL School Greece www.sqlschool.gr 2012 I became MCT Regional Lead by Microsoft Learning Program. 2013 I was certified as MCSE : Data Platform I was certified as MCSE : Business Intelligence 2016 I was certified as MCSE: Data Management & Analytics 2017 Certified as MCSA : Machine Learning Recertified as MCSE: Data Management & Analytics Antonios Chatzipavlis Data Solutions Consultant & Trainer MVP on Data Platform MCT, MCSE, MCITP, MCPD, MCSD, MCDBA, MCSA, MCTS, MCAD, MCP, OCA, ITIL-F
  • 3. Μια πηγή ενημέρωσης για την Microsoft Data Platform προς τους Έλληνες IT Professionals, DBAs, Developers, Information Workers αλλά και απλούς χομπίστες που απλά τους αρέσει ο SQL Server. Help line : [email protected] • Articles about SQL Server • SQL Server News • SQL Nights • Webcasts • Downloads • Resources What we are doing here Follow us in socials fb/sqlschoolgr fb/groups/sqlschool @antoniosch @sqlschool yt/c/SqlschoolGr SQL School Greece group SELECT KNOWLEDGE FROM SQL SERVER
  • 4. Connect with PASS Sign up for a free membership today at: pass.org is the PASS Local Group in Greece
  • 7. PRESENTATIONCONTENT • Database Structure Internals • Data File Internals • tempdb Internals
  • 9. • 32,767 Databases per instance • 524,767 TB is the max size per database • 16 TB is the max size for each data file • 2 TB is the max size for each log file • 32,767 files per database • 32,767 filegroups per database • 64 KB is the size of each Extent - 8 pages X 8 KB per page • 8 KB is the size of each Page DATABASE COMPONENTS Database File Group (one or more) Data File (one or more) Extent (mixed or uniform) Pages (8 KB each)
  • 10. File groups • Logical grouping of data files • Can bring administration and performance benefits • FILESTREAM has its own file group FILEGROUPS AND DATABASE FILES Database Files • Data Files - At least one per database - Multiple files can: - improve performance, - aid maintainability - circumvent operating system file size limitations • Transaction Log Files - Usually only one per database - No performance advantage from multiple files
  • 11. EXTENTS Comprises eight physically continuous pages Mixed shared between different database objects Uniform owned by a single database object
  • 12. PAGE STRUCTURE AND PAGE TYPES Page Types • Data (1) • Index (2) • Text (3 and 4) • Boot (13) • File Header (15) • PFS (11) • GAM (8) • SGAM (9) • IAM (10) • DIFF_MAP (16) • ML_MAP (17)
  • 13. PAGE HEADER pageID The file number and page number of this page in the database Metadata: ObjectId The ID of the object to which this page belongs slotCnt The total number of slots (rows) used on this page Metadata: PartitionId The ID of the partition that this page is part of Type Page Type Metadata: AllocUnitId The ID of the allocation unit that contains this page LSN The LSN corresponding to the last log entry that changed this page freeData The byte offset of the first free space on this page nextPage The file number and page number of the next page if this page is in a page chain Pminlen The number of bytes in fixed-length portion of rows prevPage The file number and page number of the previous page if this page is in a page chain freeCnt The number of free bytes on the page Level The level of this page in an index (always 0 for leaf pages) indexId The index ID of this page (always 0 for data pages)
  • 14. • Data rows for in-row data - The maximum size of a single data row is 8,060 bytes of in-row data. - Rows can also have row-overflow and LOB data stored on separate pages. - The number of rows stored on a given page varies depending on the table structure and on the data being stored. - A table with all fixed-length columns always can store the same number of rows per page - Variable-length rows can store as many rows as will fit based on the actual length of the data entered. - Keeping the row length shorter allows more rows to fit on a page, thus reducing I/O and increasing the likelihood that needed data can stay in cache. • Row offset array - The row offset array is a block of 2-byte entries - Each indicating the offset on the page at which the corresponding data row begins. - The row offset array indicates the logical order of rows on a page. - For example, if a table has a clustered index, SQL Server stores the rows in the order of the clustered index key. - This doesn’t mean the rows are physically stored on the page in the order of the clustered index key. - Rather, slot 0 in the offset array refers to the first row in the clustered index key order, slot 1 refers to the second row, and so forth DATA ROWS AND ROW OFFSET ARRAY
  • 15. • Status Bits A - Bit 0. This indicates special versioning information. In SQL Server 2012, this is always 0. - Bits 1 through 3. Taken as a 3-bit value, - 0(000) indicates a primary record, - 1 (001) indicates a forwarded record, - 2 (010) indicates a forwarding stub, - 3 (011) indicates an index record, - 4 (100) indicates a BLOB fragment or row-overflow data - 5(101) indicates a ghost index record - 6(110) indicates a ghost data record, - 7(111) indicates a ghost version record. - Bit 4. This indicates that a NULL bitmap exists. In SQL Server 2012, a NULL bitmap is always present, even if no NULLs are allowed in any column. - Bit 5. This indicates that variable-length columns exist in the row. - Bit 6. This indicates that the row contains versioning information. - Bit 7. This isn’t used in SQL Server 2012. • Status Bits B - The only bit used in the Status Bits B field indicates that the record is a ghost forwarded record. RECORD STRUCTURE AND RECORD TYPES
  • 16. • File Header Page (FH) • Page Free Space (PFS) • Global Allocation Map (GAM) • Shared Global Allocation Map (SGAM) • Differential Change Map (DCM) • Bulk Change Map • Boot Page • Index Allocation Map (IAM) ALLOCATION BITMAPS AND SPECIAL PAGES
  • 17. • Page allocation •The process of allocating new pages to an object • Allocation units •IN_ROW_DATA •LOB_DATA •ROW_OVERFLOW_DATA • Page allocations can be analysed using DBCC page PAGE ALLOCATION AND ALLOCATION UNITS
  • 18. DBCC PAGE DBCC PAGE ({dbid | dbname}, filenum, pagenum[, printopt]) DBCC TRACEON(3604); GO DBCC PAGE (AdventureWorks2012, 1, 266, 1);
  • 21. VOLUME CONFIGURATION BEST PRACTICES Volume RAID 10 for transaction log files RAID 10 or RAID 5 for database data files Store data and transaction log files on physically separate volumes Defragment disks frequently Size data and transaction log files to avoid auto growth
  • 22. NUMBER OF DATA FILES AND PL ACEMENT For most databases a single data file is sufficient: To improve performance:
  • 23. • Logical I/O - pages read from cache • Physical I/O - pages read from disk • You can view physical and logical I/O stats using - the DMV sys.dm_exec_query_stats or - by using the Transact-SQL command SET STATISTICS IO ON before issuing a query. - SET STATISTICS IO ON will only return statistics for queries in the current session. PHYSICAL I/O VS. LOGICAL I/O • Buffer cache hit ratio - percentage of pages read from cache without having to be read from disk - calculated by the formula ((logical reads–physical reads)/logical reads) * 100. - a SQL Server instance that is performing well will have a buffer cache hit ratio close to 100. - The buffer cache hit ratio can be improved by making more memory available to SQL Server.
  • 24. ALLOCATIONS WITHIN DATA FILES Allocation is simple in a file group that has a single file In a multifile group, SQL Server uses: • Round robin allocation • Proportional fill
  • 25. INSTANT FILE INITIALIZATION Improves performance by skipping zeroing of data pages on file creation and growth Best practice is to enable following assessment of security risk Disabled by default: security risk
  • 26. Auto Grow • Automatically expands a file when space is low • Manually manage file size for better performance • Auto grow best practices: - Leave enabled to avoid downtime in case file size limit is reached - Set to a fixed rather than a percentage AUTO GROW AND AUTO SHRINK Auto Shrink • Shrinks data file automatically to release disk space • Use with caution as: - Auto shrink causes index fragmentation - It’s uncontrollable and affects performance - It can lead to growth-shrink cycle severely affecting performance
  • 27. DATA FILE SHRINKING Shrink • Causes index fragmentation • Resource intensive • Degrades performance Best used for • Emptying a file before removing it • Changing a file or file group to read only • Reclaiming free space following large delete operation Alternative • Move all indexes to a new file group • Move heaps with shrink. Heaps are not fragmented with shrink • Remove old file group
  • 28. Database file configuration • SSMS database properties • sp_helpfile and sp_helpfilegroup • sys.database_files and sys.filegroups • sys.master_files • sys.dm_db_file_space_usage MONITORING DATABASE FILES Database file activity •SSMS Activity Monitor – Data File I/O •Wait statistics – PAGEIOLATCH_*, WRITELOG •sys.dm_io_virtual_file_stats
  • 31. TEMPDB USAGE tempdb tempdb Stores: • Internal objects • Version store • Some user objects Recreated at startup Must not be allowed to run out of space Should be actively
  • 33. VERSION STORE INTERNALS Stores all version records from all databases New allocation unit created every minute Cleanup happens every minute Nonlogged operation Version Store
  • 34. Configuration • Enable instant file initialization • Size for expected workload • Isolate tempdb data files • Use multiple data files • Enable auto growth as a contingency TEMPDB CONFIGURATION Prohibited operations • Backup and restore • Add file groups • Change collation • Set offline or read only tempdb size can be monitored using the sys.dm_db_file_space_usage DMV
  • 37. EVALUATIONS http://bit.ly/2xUr3XP EVENT EVALUATION LINK SESSIONS EVALUATION LINK http://bit.ly/2snEVoq
  • 39. SELECT KNOWLEDGE FROM SQL SERVER Copyright © 2018 SQLschool.gr. All right reserved. PRESENTER MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION