Ms sql server architecture

34,095 views
33,910 views

Published on

I updated this presentation with the help of different online sources

Published in: Technology
23 Comments
41 Likes
Statistics
Notes
No Downloads
Views
Total views
34,095
On SlideShare
0
From Embeds
0
Number of Embeds
630
Actions
Shares
0
Downloads
531
Comments
23
Likes
41
Embeds 0
No embeds

No notes for slide
  • Policy: “Declarative Management Framework” (DMF) is now “Policy Based Framework”
  • No longer limited to 8000 bytes of data, but 2GB in SS2008
  • No longer limited to 8000 bytes of data, but 2GB in SS2008
  • Ms sql server architecture

    1. 1. AgendaRelational EngineStorage EngineSQL OSNew Features of SQL Server 2012Q&A
    2. 2. SQL Server Architecture
    3. 3. Protocol Used Area
    4. 4. SQL Server ComponentsDatabasesDatabase Files and File GroupsTransaction LogsBackup and RecoveryMicrosoft Cluster ServerProtocolsDisaster Recovery
    5. 5. SQL Server DatabasesSystem databases Master Model MSDB Resource TempdbUser databases
    6. 6. SQL Server FilesBinariesDatafiles (.mdf, .ndf)Transaction log files (.ldf)Backup files and snapshot filesFile groups
    7. 7. 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.
    8. 8. 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 redone9
    9. 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
    10. 10. 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
    11. 11. Different Tasks of Relational Engine: Query Processing Memory Management Thread and Task Management Buffer Management Distributed Query Processing
    12. 12. 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 well begin the discussion on how to read such a plan. It is slightly nonsensical to those of us in Western culture and youll see why in a second.
    13. 13. 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 isnt, 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 isnt 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 clause2. WHERE clause3. GROUP BY clause4. HAVING clause5. SELECT clause6. ORDER BY clause
    14. 14. Storage EngineStorage Engine is responsible for the following:Storage of dataRetrieval of data
    15. 15. 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 cacheSELECT COUNT(*) AS cached_pages_count,name AS BaseTableName, IndexName,IndexTypeDescFROM sys.dm_os_buffer_descriptors AS bdINNER JOIN(SELECT s_obj.name, s_obj.index_id,s_obj.allocation_unit_id, s_obj.OBJECT_ID,i.name IndexName, i.type_desc IndexTypeDescFROM(
    16. 16. Database FilesWhen we talk about any database in SQL server, there are 2 types of files that are created at the disk level1.Data file2.Log file
    17. 17. 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
    18. 18. 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)Mixedb)Uniform
    19. 19. Log filesDo not contain pages; they contain a series of log records.Need to updated it ……………….
    20. 20. 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
    21. 21. 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 :
    22. 22. 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.
    23. 23. 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
    24. 24. Physical design and Index Selection Physical Dat abase Design and Tuning
    25. 25. New Features of SQL Server 2012
    26. 26. 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
    27. 27. T-SQL Data TypesGeometery (for planar shapes, i.e. whse layout)Geography (for GPS coordinates)HierarchyIDdatetimedatetime2Datetimeoffset (timezone )
    28. 28. New Features In SQL serer 2012New Data type Conversion1. PARSE Conversion Function 2. TRY_PARSE Conversion Function 3. TRY_CONVERT Conversion FunctionUses Example:SELECT StateProvinceID ,StateProvinceCode ,PARSE(StateProvinceCode AS INT) AS [Using PARSE Function] FROM Person.StateProvince WHERE CountryRegionCode IN (FR) AND Name IN (Vienne)
    29. 29. Date/Time VariablesSQL Server 2005: Type Accuracy RangeSmalldatetime 1 min 1900-1-1 to 2079-6-6Datetime 3.33 mS 1753-1-1 to 9999-12-31SQL Server 2008: Type Accuracy RangeDate 1 day 1-1-1 to 9999-12-31time 100 nS 00:00:00 to 23:59.59.9999999datetime2 100 nS 1-1-1 00:00:00 to 9999-12-31 23:59.59.9999999datetimeoffset 100 nS 1-1-1 00:00:00 to 9999-12-31 23:59.59.9999999
    30. 30. FilestreamFilestream storage attribute on varbinary(max) columnIncludes transactional access through Win32 API PathName() Get_Filestream_Transaction_context() OpenSqlFileStream()
    31. 31. 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*/
    32. 32.  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.
    33. 33. 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 ofIndependent 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.
    34. 34. Failover clustering:•Microsoft SQL Server failover clustering is designed to failover automatically if a hardware failure ora 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 EditionMicrosoft Windows 2000 Advanced ServerMicrosoft Windows 2000 Datacenter ServerMicrosoft Windows Server 2003, Enterprise EditionMicrosoft Windows Server 2003, Datacenter EditionMicrosoft Cluster Service (MSCS): To implement failover clustering for SQLServer, you must install MSCS from operating systems.
    35. 35. 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 levelAdvantages• 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 anothercomputer over a network. Therefore, the security of the information that SQL Server transfers isvery important
    36. 36. 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 dataAdvantages:•Read performance is improved because you can spread activity across all nodes.•Aggregate update performance, insert performance, and delete performance for the topologyresembles 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 thepotential 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 singlepublication 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 subscriptionsynchronization 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.
    37. 37. Configure Replication for Always On Availability Groups1. 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.

    ×