SlideShare a Scribd company logo
1 of 39
Agenda
Relational Engine
Storage Engine
SQL OS
New Features of SQL Server 2012
Q&A
SQL Server Architecture
Protocol Used Area
SQL Server Components
Databases
Database Files and File Groups
Transaction Logs
Backup and Recovery
Microsoft Cluster Server
Protocols
Disaster Recovery
SQL Server Databases
System databases
  Master
  Model
  MSDB
  Resource
  Tempdb
User databases
SQL Server Files
Binaries
Datafiles (.mdf, .ndf)
Transaction log files (.ldf)
Backup files and snapshot files
File groups
SQL Server Transaction Log



    When the end of the logical log reaches the end of the physical log file,
    the new log records wrap around to the start of the physical log file.
SQL Server Recovery Model
    Recovery    Description    Work Loss Exposure           Recover to point
    Model                                                   in time?
    Simple      No log         Changes since the most       Can recover only to
                backups        recent backup are            the end of a backup
                               unprotected
    Full        Requires log   Normally none                Can recover to a
                backups                                     specific point in
                                                            time
    Bulk logged Requires log   If the log is damaged or     Point in time is not
                backups        bulk-logged operations       supported
                               occurred since the most
                               recent log backup, changes
                               since the last backup must
                               be redone




9
Microsoft Cluster Server

Elements of a Failover Cluster Instance
       A failover cluster instance can run on one or more computers that are participating nodes of a failover
        cluster. The number of participating nodes is limited only by the operating system.
       A failover cluster instance contains:
            A combination of one or more disks in a Microsoft Cluster Service (MSCS) cluster group, also known as
             a resource group.
            Each resource group can contain at most one instance of SQL Server.
            A network name for the failover cluster instance.
            One or more IP addresses assigned to the failover cluster instance.
            One instance of SQL Server 2005 that includes SQL Server, SQL Server Agent, and the Full-text Search
             (FTS) service.

Implementation Considerations
       Hardware
       Software
       Network
Relational Engine
Query Processor
It includes the components of SQL Server that
 determine what your query exactly needs to do and
 the best way to do it. It manages the execution of
 queries as it requests data from the storage engine
 and processes the results returned
Different Tasks of Relational Engine:

  Query Processing
  Memory Management
  Thread and Task Management
  Buffer Management
  Distributed Query Processing
Query Processing

 SELECT SQL Statement (SELECT [CustomerID], [CompanyName], [City], [Region]
   FROM [Northwind].[dbo].[Customers]
   WHERE [Country] = 'Germany'
   ORDER BY [CompanyName]) then
                            press Ctrl+K,it will display the following:
 Reading the Graphical Execution Plan
 the execution plan for the aforementioned query and we'll begin the
  discussion on how to read such a plan. It is slightly nonsensical to those of us
  in Western culture and you'll see why in a second.
Select “where clause” evaluation order

 select a from table where c=1 and d=2
• There are no guarantees for evaluation order. The optimizer will try to find the most
  efficient way to execute the query, using available information.
• In above case, since c is indexed(assume) and d isn't, the optimizer should look into the
  index to find all rows that match the predicate on c, then retrieve those rows from the
  table data to evaluate the predicate on d.
• However, if it determines that the index on c isn't very selective (although not in
  example, a gender column is rarely usefully indexed), it may decide to do the table scan
  anyway, but Default order is :
1.   FROM clause
2.   WHERE clause
3.   GROUP BY clause
4.   HAVING clause
5.   SELECT clause
6.   ORDER BY clause
Storage Engine
Storage Engine is responsible for the following:



Storage of data


Retrieval of data
Data Pages in Buffer Pool – Data Stored in Memory Cache


   • if there is any way one can know how much data in a table is stored
     in the memory cache?
   • if there are multiple indexes on table (and used in a query), were the
     data of the single table stored multiple times in the memory cache or
     only for a single time?

    Query ,run to figure out what kind of data is stored in the cache
SELECT COUNT(*) AS cached_pages_count,
name AS BaseTableName, IndexName,
IndexTypeDesc
FROM sys.dm_os_buffer_descriptors AS bd
INNER JOIN
(
SELECT s_obj.name, s_obj.index_id,
s_obj.allocation_unit_id, s_obj.OBJECT_ID,
i.name IndexName, i.type_desc IndexTypeDesc
FROM
(
Database Files
When we talk about any database in SQL server,

 there are   2 types of files that are created at the disk
 level

1.Data file
2.Log file
Data file
 Data file physically stores the data in data pages.
The size for Data Page is 8KB.
Data pages are logically organized in extents
Extents
Extents are logical units in the database
combination of 8 data pages i.e. 64 KB forms an
  extent
Extents can be of two types:
a)Mixed
b)Uniform
Log files
Do not contain pages; they contain a series of log
 records.
Need to updated it ……………….
Log files
It also known as write ahead log.
 It stores modification to the database (DML and DDL).
Sufficient information is logged to be able to:
  Roll back transactions if requested
  Recover the database in case of failure
  Write Ahead Logging is used to create log entries
     Transaction  logs are written in chronological order in
      a circular way
     Truncation policy for logs is based on the recovery
      model
SQL OS

This lies between the host machine (Windows OS)
 and SQL Server
All the activities performed on database engine are
 taken care of by SQL OS
It is a highly configurable operating system with
 powerful API (application programming interface)
It enables automatic locality and advanced
 parallelism
SQL OS provides various operating system services :
As mentioned in below :
SQL OS

Memory Management
Buffer Pool
Log Buffer
Deadlock detection using blocking and locking
 structure.
Other Services. It includes following:
  exception handling,
  hosting for external components like Common
    Language Runtime, CLR etc.
Partitioning
Allows tables and indexes to be split into a series of
 ranges, with each range stored separately (most commonly
 in separate file groups).
Each table or index can have up to 1000 partitions.
250 indexes x 1000 partitions x 3 allocation units = 750000
 IAM chains.
Create Partition only on very large table.
Avoid it on small table/index
Physical design and Index Selection

         Physical Dat abase
         Design and Tuning
New Features of SQL Server 2012
T-SQL Features
   Table Value Parameters
   FileStream Object Storage
   Merge
   Variable initializers
   Row constructors with >1 row
   Compound operators (+=)
   Grouping sets (extension of Group By clause)
   Intellisense added
   New Collations
   CLR UDT 2GB capacity
   Integrated Full Text Search
   Sparse Columns (Indexing)
   Sequence
   Page Data
   Exception Handling
   Enhanced EXECUTE keyword
   Get Metadata
T-SQL Data Types
Geometery (for planar shapes, i.e. whse layout)
Geography (for GPS coordinates)
HierarchyID
date
time
datetime2
Datetimeoffset (timezone )
New Features In SQL serer 2012
New Data type Conversion
1. PARSE Conversion Function
  2. TRY_PARSE Conversion Function
  3. TRY_CONVERT Conversion Function
Uses Example:
SELECT StateProvinceID ,StateProvinceCode
  ,PARSE(StateProvinceCode AS INT) AS [Using PARSE
  Function] FROM Person.StateProvince WHERE
  CountryRegionCode IN ('FR') AND Name IN
  ('Vienne')
Date/Time Variables
SQL Server 2005:
       Type                Accuracy                  Range
Smalldatetime    1 min                1900-1-1 to 2079-6-6
Datetime         3.33 mS              1753-1-1 to 9999-12-31



SQL Server 2008:
       Type                Accuracy                 Range
Date             1 day                1-1-1 to 9999-12-31
time             100 nS               00:00:00 to 23:59.59.9999999
datetime2        100 nS               1-1-1 00:00:00 to
                                      9999-12-31 23:59.59.9999999
datetimeoffset   100 nS               1-1-1 00:00:00 to
                                      9999-12-31 23:59.59.9999999
Filestream
Filestream storage attribute on varbinary(max)
 column
Includes transactional access through Win32 API
  PathName()
  Get_Filestream_Transaction_context()
  OpenSqlFileStream()
Other Important Features
OVER Clause is enhanced with ROWS/RANGE
  Clause to limit the rows
 Suppose, to calculate sum of last 5 yrs revenue for every row,
 Ex.ROWS BETWEEN 4 PRECEDING AND CURRENT ROW
 Suppose to calculate sum of all preceding years(Cumulative sum),
 Ex.ROWS UNBOUNDED PRECEDING
 SQL Server 2012 provides a function EOMONTH() to calculate end
  date of a month.
 DECLARE @Currentdate DATETIME SET @Currentdate = '12/12/2010'
  SELECT EOMONTH ( @Currentdate ) AS EndofMonth;
 /*Result: 2010-12-31*/
 FORCESEEK hint is extended to specify columns used to seek in the specified index
 SELECT CompanyID,CompanyName,Amount
 FROM COMPANIES
 WITH (FORCESEEK(Idx_Company(CompanyID)))
 WHERE CompanyID = 1
 OVER Clause is enhanced to apply aggregate functions while applying "Order By“
 SUM(Amount) OVER (PARTITION BY CompanyID ORDER BY Year)
 Ex. SELECT CompanyId,[Year],Amount,
 SUM(Amount) OVER (PARTITION BY CompanyID
 ORDER BY [Year]) AS CumulativeRevenue
 FROM @Companies
 LOG function has been enhanced to accept any base
 SELECT LOG(10) as Result -- Returns natural logarithm value of 10. Natural base is e. its
  value 2.718
 SELECT LOG(9,3) as Result1-- Returns logarithm value of base 3.
Disaster         recovery :
disasters include :
•A natural or a man-made disaster such as a fire,
•A technical disaster such as a two-disk failure in a Redundant Array of
Independent Disks (RAID) 5 array
•Recovery:
A process that you can use to help recover information systems and data


Before you decide on which disaster recovery solution is best for you


look at each of the suggested disaster recovery solutions in more detail.
Failover clustering:
•Microsoft SQL Server failover clustering is designed to failover automatically if a hardware failure or
a software failure occurs.

•failover clustering is designed for high server availability with almost no server downtime
•To implement failover clustering, you must install Microsoft SQL Server Enterprise Edition.


The following operating systems support failover clustering:

Microsoft Windows NT 4.0, Enterprise Edition
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Datacenter Server
Microsoft Windows Server 2003, Enterprise Edition
Microsoft Windows Server 2003, Datacenter Edition

Microsoft Cluster Service (MSCS): To implement failover clustering for SQL
Server, you must install MSCS from operating systems.
Database mirroring

             •   Solution for increasing database availability
             •   can only implement mirroring on a per-database basis
             •   Mirroring only works with databases that use the full recovery model
             •   Database mirroring works with any supported database compatibility level

Advantages
• Database mirroring increases data protection.
• Database mirroring increases availability of a database.
• Database mirroring improves the availability of the production database during upgrades.

Disadvantages

•The mirror database should be identical to the principal database. For example, all objects,
logins, and permissions should be identical.


•Database mirroring involves the transfer of information from one computer to another
computer over a network. Therefore, the security of the information that SQL Server transfers is
very important
Peer-to-peer transactional replication

    • Peer-to-peer transactional replication is designed for applications that
      might read or might modify the data in any database that participates
      in replication
    • if any servers that host the databases are unavailable, you can modify
      the application to route traffic to the remaining servers. The remaining
      servers contain identical copies of the data
Advantages:
•Read performance is improved because you can spread activity across all nodes.
•Aggregate update performance, insert performance, and delete performance for the topology
resembles the performance of a single node because all changes are propagated to all nodes.
Disadvantages:
•Peer-to-peer replication is available only in SQL Server 2005 Enterprise Edition.
•All participating databases must contain identical schemas and data.
•We recommend that each node use its own distribution database. This configuration eliminates the
potential for SQL Server 2005 to have a single point of failure.
•You cannot include tables and other objects in multiple peer-to-peer publications within a single
publication database.
•You must have a publication enabled for peer-to-peer replication before you create any subscriptions.
•You must initialize subscriptions by using a backup or by setting the value of the subscription
synchronization type to replication support only.
•Peer-to-peer transactional replication does not provide conflict detection or conflict resolution.
•We recommend that you do not use identity columns.
Configure Replication for Always On Availability Groups


1.   Configure the database publications and subscriptions.
2.   Configure the Always On availability group.
3.   Insure that all secondary replica hosts are configured for replication.
4.   Configure the secondary replica hosts as replication publishers.
5.   Redirect the original publisher to the Availability Group Listener Name.
6.   Run the validation stored procedure to verify the configuration.
7.   Add the original publisher to Replication Monitor.
Ms sql server architecture

More Related Content

What's hot

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
honglee71
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
Simon Huang
 
MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
Abdul Manaf
 
Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
Amit Bhalla
 

What's hot (20)

Microsoft SQL Server Database Administration.pptx
Microsoft SQL Server Database Administration.pptxMicrosoft SQL Server Database Administration.pptx
Microsoft SQL Server Database Administration.pptx
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginners
 
Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret Internals
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)
 
Oracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12cOracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12c
 
MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Oracle GoldenGate
Oracle GoldenGate Oracle GoldenGate
Oracle GoldenGate
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
My SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please helpMy SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please help
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
 
The oracle database architecture
The oracle database architectureThe oracle database architecture
The oracle database architecture
 

Similar to Ms sql server architecture

SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
Jerry Yang
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
Concentrated Technology
 

Similar to Ms sql server architecture (20)

Sql server
Sql serverSql server
Sql server
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
 
Sql server
Sql serverSql server
Sql server
 
Sql Server
Sql ServerSql Server
Sql Server
 
ora_sothea
ora_sotheaora_sothea
ora_sothea
 
SQL Server 2019 ctp2.2
SQL Server 2019 ctp2.2SQL Server 2019 ctp2.2
SQL Server 2019 ctp2.2
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldev
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developers
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 
Azure SQL - more or/and less than SQL Server
Azure SQL - more or/and less than SQL ServerAzure SQL - more or/and less than SQL Server
Azure SQL - more or/and less than SQL Server
 
Fudcon talk.ppt
Fudcon talk.pptFudcon talk.ppt
Fudcon talk.ppt
 
Module02
Module02Module02
Module02
 
Investigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock HolmesInvestigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock Holmes
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Ms sql server architecture

  • 1.
  • 2. Agenda Relational Engine Storage Engine SQL OS New Features of SQL Server 2012 Q&A
  • 5. SQL Server Components Databases Database Files and File Groups Transaction Logs Backup and Recovery Microsoft Cluster Server Protocols Disaster Recovery
  • 6. SQL Server Databases System databases Master Model MSDB Resource Tempdb User databases
  • 7. SQL Server Files Binaries Datafiles (.mdf, .ndf) Transaction log files (.ldf) Backup files and snapshot files File groups
  • 8. SQL Server Transaction Log When the end of the logical log reaches the end of the physical log file, the new log records wrap around to the start of the physical log file.
  • 9. SQL Server Recovery Model Recovery Description Work Loss Exposure Recover to point Model in time? Simple No log Changes since the most Can recover only to backups recent backup are the end of a backup unprotected Full Requires log Normally none Can recover to a backups specific point in time Bulk logged Requires log If the log is damaged or Point in time is not backups bulk-logged operations supported occurred since the most recent log backup, changes since the last backup must be redone 9
  • 10. Microsoft Cluster Server Elements of a Failover Cluster Instance  A failover cluster instance can run on one or more computers that are participating nodes of a failover cluster. The number of participating nodes is limited only by the operating system.  A failover cluster instance contains:  A combination of one or more disks in a Microsoft Cluster Service (MSCS) cluster group, also known as a resource group.  Each resource group can contain at most one instance of SQL Server.  A network name for the failover cluster instance.  One or more IP addresses assigned to the failover cluster instance.  One instance of SQL Server 2005 that includes SQL Server, SQL Server Agent, and the Full-text Search (FTS) service. Implementation Considerations  Hardware  Software  Network
  • 11. Relational Engine Query Processor It includes the components of SQL Server that determine what your query exactly needs to do and the best way to do it. It manages the execution of queries as it requests data from the storage engine and processes the results returned
  • 12. Different Tasks of Relational Engine: Query Processing Memory Management Thread and Task Management Buffer Management Distributed Query Processing
  • 13. Query Processing  SELECT SQL Statement (SELECT [CustomerID], [CompanyName], [City], [Region] FROM [Northwind].[dbo].[Customers] WHERE [Country] = 'Germany' ORDER BY [CompanyName]) then press Ctrl+K,it will display the following:  Reading the Graphical Execution Plan  the execution plan for the aforementioned query and we'll begin the discussion on how to read such a plan. It is slightly nonsensical to those of us in Western culture and you'll see why in a second.
  • 14. Select “where clause” evaluation order select a from table where c=1 and d=2 • There are no guarantees for evaluation order. The optimizer will try to find the most efficient way to execute the query, using available information. • In above case, since c is indexed(assume) and d isn't, the optimizer should look into the index to find all rows that match the predicate on c, then retrieve those rows from the table data to evaluate the predicate on d. • However, if it determines that the index on c isn't very selective (although not in example, a gender column is rarely usefully indexed), it may decide to do the table scan anyway, but Default order is : 1. FROM clause 2. WHERE clause 3. GROUP BY clause 4. HAVING clause 5. SELECT clause 6. ORDER BY clause
  • 15. Storage Engine Storage Engine is responsible for the following: Storage of data Retrieval of data
  • 16. Data Pages in Buffer Pool – Data Stored in Memory Cache • if there is any way one can know how much data in a table is stored in the memory cache? • if there are multiple indexes on table (and used in a query), were the data of the single table stored multiple times in the memory cache or only for a single time? Query ,run to figure out what kind of data is stored in the cache SELECT COUNT(*) AS cached_pages_count, name AS BaseTableName, IndexName, IndexTypeDesc FROM sys.dm_os_buffer_descriptors AS bd INNER JOIN ( SELECT s_obj.name, s_obj.index_id, s_obj.allocation_unit_id, s_obj.OBJECT_ID, i.name IndexName, i.type_desc IndexTypeDesc FROM (
  • 17. Database Files When we talk about any database in SQL server, there are 2 types of files that are created at the disk level 1.Data file 2.Log file
  • 18. Data file  Data file physically stores the data in data pages. The size for Data Page is 8KB. Data pages are logically organized in extents
  • 19. Extents Extents are logical units in the database combination of 8 data pages i.e. 64 KB forms an extent Extents can be of two types: a)Mixed b)Uniform
  • 20. Log files Do not contain pages; they contain a series of log records. Need to updated it ……………….
  • 21. Log files It also known as write ahead log.  It stores modification to the database (DML and DDL). Sufficient information is logged to be able to: Roll back transactions if requested Recover the database in case of failure Write Ahead Logging is used to create log entries  Transaction logs are written in chronological order in a circular way  Truncation policy for logs is based on the recovery model
  • 22. SQL OS This lies between the host machine (Windows OS) and SQL Server All the activities performed on database engine are taken care of by SQL OS It is a highly configurable operating system with powerful API (application programming interface) It enables automatic locality and advanced parallelism SQL OS provides various operating system services : As mentioned in below :
  • 23. SQL OS Memory Management Buffer Pool Log Buffer Deadlock detection using blocking and locking structure. Other Services. It includes following: exception handling, hosting for external components like Common Language Runtime, CLR etc.
  • 24. Partitioning Allows tables and indexes to be split into a series of ranges, with each range stored separately (most commonly in separate file groups). Each table or index can have up to 1000 partitions. 250 indexes x 1000 partitions x 3 allocation units = 750000 IAM chains. Create Partition only on very large table. Avoid it on small table/index
  • 25. Physical design and Index Selection Physical Dat abase Design and Tuning
  • 26. New Features of SQL Server 2012
  • 27. T-SQL Features  Table Value Parameters  FileStream Object Storage  Merge  Variable initializers  Row constructors with >1 row  Compound operators (+=)  Grouping sets (extension of Group By clause)  Intellisense added  New Collations  CLR UDT 2GB capacity  Integrated Full Text Search  Sparse Columns (Indexing)  Sequence  Page Data  Exception Handling  Enhanced EXECUTE keyword  Get Metadata
  • 28. T-SQL Data Types Geometery (for planar shapes, i.e. whse layout) Geography (for GPS coordinates) HierarchyID date time datetime2 Datetimeoffset (timezone )
  • 29. New Features In SQL serer 2012 New Data type Conversion 1. PARSE Conversion Function 2. TRY_PARSE Conversion Function 3. TRY_CONVERT Conversion Function Uses Example: SELECT StateProvinceID ,StateProvinceCode ,PARSE(StateProvinceCode AS INT) AS [Using PARSE Function] FROM Person.StateProvince WHERE CountryRegionCode IN ('FR') AND Name IN ('Vienne')
  • 30. Date/Time Variables SQL Server 2005: Type Accuracy Range Smalldatetime 1 min 1900-1-1 to 2079-6-6 Datetime 3.33 mS 1753-1-1 to 9999-12-31 SQL Server 2008: Type Accuracy Range Date 1 day 1-1-1 to 9999-12-31 time 100 nS 00:00:00 to 23:59.59.9999999 datetime2 100 nS 1-1-1 00:00:00 to 9999-12-31 23:59.59.9999999 datetimeoffset 100 nS 1-1-1 00:00:00 to 9999-12-31 23:59.59.9999999
  • 31. Filestream Filestream storage attribute on varbinary(max) column Includes transactional access through Win32 API PathName() Get_Filestream_Transaction_context() OpenSqlFileStream()
  • 32. Other Important Features OVER Clause is enhanced with ROWS/RANGE Clause to limit the rows  Suppose, to calculate sum of last 5 yrs revenue for every row,  Ex.ROWS BETWEEN 4 PRECEDING AND CURRENT ROW  Suppose to calculate sum of all preceding years(Cumulative sum),  Ex.ROWS UNBOUNDED PRECEDING  SQL Server 2012 provides a function EOMONTH() to calculate end date of a month.  DECLARE @Currentdate DATETIME SET @Currentdate = '12/12/2010' SELECT EOMONTH ( @Currentdate ) AS EndofMonth;  /*Result: 2010-12-31*/
  • 33.  FORCESEEK hint is extended to specify columns used to seek in the specified index  SELECT CompanyID,CompanyName,Amount  FROM COMPANIES  WITH (FORCESEEK(Idx_Company(CompanyID)))  WHERE CompanyID = 1  OVER Clause is enhanced to apply aggregate functions while applying "Order By“  SUM(Amount) OVER (PARTITION BY CompanyID ORDER BY Year)  Ex. SELECT CompanyId,[Year],Amount,  SUM(Amount) OVER (PARTITION BY CompanyID  ORDER BY [Year]) AS CumulativeRevenue  FROM @Companies  LOG function has been enhanced to accept any base  SELECT LOG(10) as Result -- Returns natural logarithm value of 10. Natural base is e. its value 2.718  SELECT LOG(9,3) as Result1-- Returns logarithm value of base 3.
  • 34. Disaster recovery : disasters include : •A natural or a man-made disaster such as a fire, •A technical disaster such as a two-disk failure in a Redundant Array of Independent Disks (RAID) 5 array •Recovery: A process that you can use to help recover information systems and data Before you decide on which disaster recovery solution is best for you look at each of the suggested disaster recovery solutions in more detail.
  • 35. Failover clustering: •Microsoft SQL Server failover clustering is designed to failover automatically if a hardware failure or a software failure occurs. •failover clustering is designed for high server availability with almost no server downtime •To implement failover clustering, you must install Microsoft SQL Server Enterprise Edition. The following operating systems support failover clustering: Microsoft Windows NT 4.0, Enterprise Edition Microsoft Windows 2000 Advanced Server Microsoft Windows 2000 Datacenter Server Microsoft Windows Server 2003, Enterprise Edition Microsoft Windows Server 2003, Datacenter Edition Microsoft Cluster Service (MSCS): To implement failover clustering for SQL Server, you must install MSCS from operating systems.
  • 36. Database mirroring • Solution for increasing database availability • can only implement mirroring on a per-database basis • Mirroring only works with databases that use the full recovery model • Database mirroring works with any supported database compatibility level Advantages • Database mirroring increases data protection. • Database mirroring increases availability of a database. • Database mirroring improves the availability of the production database during upgrades. Disadvantages •The mirror database should be identical to the principal database. For example, all objects, logins, and permissions should be identical. •Database mirroring involves the transfer of information from one computer to another computer over a network. Therefore, the security of the information that SQL Server transfers is very important
  • 37. Peer-to-peer transactional replication • Peer-to-peer transactional replication is designed for applications that might read or might modify the data in any database that participates in replication • if any servers that host the databases are unavailable, you can modify the application to route traffic to the remaining servers. The remaining servers contain identical copies of the data Advantages: •Read performance is improved because you can spread activity across all nodes. •Aggregate update performance, insert performance, and delete performance for the topology resembles the performance of a single node because all changes are propagated to all nodes. Disadvantages: •Peer-to-peer replication is available only in SQL Server 2005 Enterprise Edition. •All participating databases must contain identical schemas and data. •We recommend that each node use its own distribution database. This configuration eliminates the potential for SQL Server 2005 to have a single point of failure. •You cannot include tables and other objects in multiple peer-to-peer publications within a single publication database. •You must have a publication enabled for peer-to-peer replication before you create any subscriptions. •You must initialize subscriptions by using a backup or by setting the value of the subscription synchronization type to replication support only. •Peer-to-peer transactional replication does not provide conflict detection or conflict resolution. •We recommend that you do not use identity columns.
  • 38. Configure Replication for Always On Availability Groups 1. Configure the database publications and subscriptions. 2. Configure the Always On availability group. 3. Insure that all secondary replica hosts are configured for replication. 4. Configure the secondary replica hosts as replication publishers. 5. Redirect the original publisher to the Availability Group Listener Name. 6. Run the validation stored procedure to verify the configuration. 7. Add the original publisher to Replication Monitor.

Editor's Notes

  1. Policy: “Declarative Management Framework” (DMF) is now “Policy Based Framework”
  2. No longer limited to 8000 bytes of data, but 2GB in SS2008
  3. No longer limited to 8000 bytes of data, but 2GB in SS2008