Presentation is loading. Please wait.

Presentation is loading. Please wait.

Seven Awesome SQL Server Features

Similar presentations


Presentation on theme: "Seven Awesome SQL Server Features"— Presentation transcript:

1 Seven Awesome SQL Server Features
That You Can Use for Free Allison Benneth @SQLTran

2 SQL Server Editions Enterprise Developer * Datacenter
SQL2008R2 SQL2012 SQL2014 SQL2016 Enterprise Developer * Datacenter Business Intelligence Standard Workgroup Web Express with Advanced Services Express LocalDB Licensing is complicated, particularly when factoring in virtualization and high availability. For simplicity’s sake, consider a stand-alone physical system with 4 cores. Based on MSRP, Enterprise Edition for SQL Server 2016 will cost about $28,500 and Standard Edition will be about $7,500 (but can be less if a small number of clients use the server). Prices for Web edition are not published. See * Free starting with SQL Server 2016

3 2016 Was a Game-Changer! A lot changed in 2016
March 7 – Microsoft announces SQL Server will be available on Linux in mid-2017 June 1 – SQL Server 2016 is released November 16 – Service Pack 1 is released Many formerly Enterprise Edition features are moved into lower SKUs Including Express Edition and LocalDB! Differentiation by scale, not by feature

4 New Features in Express Edition (2016)
SQL 2016 RTM SQL 2016 Service Pack 1 Auditing Stretch DB Polybase (compute node) In-Memory Tables Query Store Additional FILESTREAM support Columnstore JSON support Snapshots Temporal tables DBCC CLONEDATABASE Partitioning T-SQL additions Management Studio – now a separate install … and free to use Data compression DROP IF EXISTS AT TIME ZONE Row-level security SESSION_CONTEXT Always Encrypted STRING_SPLIT Dynamic data masking Features that won’t be discussed in this session: StretchDB – Selectively split a table between on premise and Azure. Query Store – (More of a DBA feature) – Maintains performance-related info about individual queries for later analysis. JSON support – Version 1 product, not very full featured. Not a native datatype, unlike XML. Mostly functions to support JSON. DROP IF EXISTS AT TIME ZONE SESSION_CONTEXT Data Compression – At the page level or at the row level. Very useful given the 10GB limit. Dynamic data masking – Applying a masking function to a column to render the data partially unreadable. Auditing – Tracking when and who accesses or modifies data. Not full-featured, but “fine-grained.” Polybase – Like Hadoop. Requires Enterprise Edition for the head node, but any other edition can be used as a compute node. FILESTREAM – Store BLOBs in a virtual file system managed by the RDBMS. DBCC CLONEDATABASE – Make a copy of a database without data, but with all other objects, including statistics, intact. Useful for performance testing query changes. All of these features, of course, are in more advanced editions as your application grows!

5 Limitations on Express Edition
Performance One CPU / four cores – per instance 1.4 GB RAM (buffer pool) – per instance 350 MB for in-memory tables – per instance, not counted toward buffer pool limit – single-threaded only 350 MB for columnstore data – per database, not counted toward buffer pool limit – single-threaded only Functionality 10 GB per database No SQL Agent (service installed, but cannot be started) Schedule backups and other jobs via another SQL Agent or OS scheduler (sqlcmd or PowerShell)

6 Limitations on Express Edition
Overcomeable Limitations No TCP/IP by default; be sure to enable it Feature Limitations Availability Groups Mirroring Polybase (head node) No SSIS, SSAS, R Server, etc. SSRS with “Express with Advanced Services” Beware! Mandatory telemetry

7 Cumulative Updates Bug fixes specific to a SQL Server version and service pack Typically issued by Microsoft about every two months Are “cumulative,” so only need the most recent update Since SP1 contained new functionality, particularly import to apply Recent CUs go through more rigorous testing; MS recommends applying them by default Current CU for SQL Server 2016 SP1 is CU2 (March 22, 2017)

8 SQL Server 2017 Until April 19, simply referred to as vNext
Current on CTP 2.0 (6th preview version) (SQL Server 2016 had 10 preview versions) No release date announced as of yet No edition announcements as of yet New features: availability on Linux, Python integration, adaptive query plans, graph databases

9 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

10 Row-Level Security Powerful and flexible way to control who can view or modify data at the row-level grain Access is controlled by a user-defined function that is applied to the table’s security Non-qualifying rows are silently blocked Select predicate – controls read access to the row Block predicate – controls modification to the row (either before or after the modification)

11 Row-Level Security DEMO

12 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

13 Always Encrypted Applies at the column level
SQL Server box never sees data in unencrypted form (both at-rest and in-transit) Encrypted columns are stored (and transmitted) as varbinary behind the scenes Certificate is generated on client machine and shared with other clients Most DBAs – myself included – don’t seem to like this feature. It appears to be designed for hosted SQL environments where the people managing the databases aren’t fully trusted.

14 Always Encrypted Encryption can be random or deterministic (required if column is indexed or used in a join) Requires a change to the connection string in the application Column Encryption Setting=enabled Queries must be parameterized Most DBAs – myself included – don’t seem to like this feature. It appears to be designed for hosted SQL environments where the people managing the databases aren’t fully trusted.

15 Always Encrypted in Action

16 Always Encrypted - Cons
Data size bloat, especially for smaller data types Adds considerable difficulty troubleshooting in tools like SSMS String columns must have a BIN collation – they won’t sort by traditional SQL rules Extra round trips to determine metadata, retrieve keys Storage bloat: Any input data type that is less than 16 bytes get stored as 65 bytes, so (for instance) an integer value (4 bytes) is stored as 65 bytes, an overhead of 16+ fold!

17 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

18 Snapshots Provides a transactionally consistent, read-only point-in-time view of a database Can take multiple snapshots at different points on the same database Useful for stable reporting against a transactional system Can be used to revert to a previous database state Failed upgrade / administrative tasks QA cycles Resources required dependent mostly on how much underlying database is changed Absolutely, positively not a substitute for proper backups!

19 Snapshots DEMO

20 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

21 Temporal Tables Most applications / databases inherently contain a temporal element If temporal components are tracked, traditionally done with triggers or change detection Temporal tables handle tracking automatically Allows greatly simplified point-in-time querying Requires additional columns on source table and requires history table Schema changes in source table are reflected in the history table

22 Temporal Tables DEMO

23 Temporal Tables Temporal querying: FROM TableName FOR SYSTEM_TIME _____ Point in time AS OF ' :30:00' Full history ALL Between (‘start’ < EndTime AND ‘end’ >= StartTime) BETWEEN ' :55:04' AND ' :30:00' From (‘start’ < EndTime AND ‘end’ > StartTime) FROM ' :55:04' TO ' :30:00' Contained in (‘start’ <= EndTime AND ‘end’ >= StartTime) CONTAINED IN (' :55:04', ' :30:00')

24 Temporal Tables Performance
Insert operations – no difference than non-temporal tables Update operations – overhead due to writes to both source and history tables Read operations – Default clustered index on history table usually not helpful – consider changing it

25 Temporal Tables Beware of v1 limitations!
Dropping a column in the source table will drop the column in the history table – all history is lost! Cannot add a non-nullable column to the source table Pruning history is an offline operation

26 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

27 Columnstore Indexes Traditional indexes are row-based copies of selected columns in table Columnstore turns this around and orders the index by column Can be the entire table (clustered index) or a subset of columns (nonclustered index) Can be combined with row-based indexes

28 Columnstore Indexes Previous versions of SQL Server imposed limitations, but SQL Server 2016 removes many of these limits Particularly useful for warehouse / analytic queries However performance usually degrades for OLTP workloads Much of performance benefit derives from high compression of columnstore (typically 20x or more)

29 Columnstore Indexes DEMO

30 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

31 Partitioning Spread table data across multiple B-trees
For example, place older data on slower, cheaper storage Usually for very large data sets, but has other purposes Separation defined by a “partitioning function” and a “partitioning scheme” Range LEFT (think of as >=) Range RIGHT (think of as <) Another use: combine with temporal tables to enable quick archival capability

32 Traditional SQL Server Index

33 Partitioned SQL Server Index

34 Partitioning DEMO

35 SQL Server Features (Speed Dating)
Security Row-Level Security Always Encrypted Utility Snapshots Temporal Tables Performance Columnstore Indexes Partitioning In-Memory OLTP (Hekaton)

36 In-Memory OLTP First introduced in SQL Server 2014
Stores data in memory Lock-free structures Multi-version concurrency control (optimistic) Fully ACID compliant (durability optional) Designed for OLTP workloads Can yield 10-20x performance boost Native compilation of stored procedures

37 In-Memory OLTP DEMO

38 In-Memory OLTP Need to give a table hint such as with (snapshot) when used inside an explicit transaction Or, set database option memory_optimized_elevate_to_snapshot Error handling considerations Entire transaction will roll back if validation phase fails (optimistic concurrency assumptions failure) Sometimes the assumptions for optimistic concurrency aren’t accurate. For example, two concurrent transactions may attempt to update the same row within the span of their transactions. Application that execute against in-memory tables should be aware of four specific error codes that may be generated out of SQL Server and be prepared to handle these gracefully. Typically, developers will want to implement retry logic similar to deadlock handling. However, be aware that when one of these errors is generated, the entire transaction is rolled back, so things become much more complicated when multi-statement transactions are in play. Application that implement retry logic will have to replay the entire transaction!

39 Resources SQL Server 2016 Express Edition download Companion blog page to this session Allison Benneth @SQLTran


Download ppt "Seven Awesome SQL Server Features"

Similar presentations


Ads by Google