Upload
itcamp
View
760
Download
1
Embed Size (px)
DESCRIPTION
Citation preview
itcampro @ itcamp12 # Premium conference on Microsoft technologies
SQL Server 2012 for developers
Cristian Lefter, SQL Server MVP
http://about.me/CristianLefter
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development ITCamp 2012 sponsors
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• Columnstore indexes
• Business Intelligence Development Studio
• SQL Server Express LocalDB
• Transact-SQL improvements
• Extended Events enhancements
• SQL Server 2012 certification
• Next steps
Agenda
itcampro @ itcamp12 # Premium conference on Microsoft technologies
COLUMNSTORE INDEXES
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development Columnstore indexes Row Store (Heap / B-Tree)
ProductID OrderDate Cost
310 20010701 2171.29
311 20010701 1912.15
312 20010702 2171.29
313 20010702 413.14
Column Store (values compressed)
5
data page 1000
ProductID OrderDate Cost
314 20010701 333.42
315 20010701 1295.00
316 20010702 4233.14
317 20010702 641.22
data page 1001
ProductID
310
311
312
313
314
315
316
317
318
319
320
321
data page 2001
OrderDate
20010701
…
20010702
…
…
20010703
…
…
…
…
20010704
…
data page 2000
data page 2002
Cost
2171.29
1912.15
2171.29
413.14
333.42
1295.00
4233.14
641.22
24.95
64.32
1111.25
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• Performance improvements for “typical” data
warehouse queries from 10x to 100x
• Ideal candidates include queries against star
schemas that use filtering, aggregations and
grouping against very large fact tables
Columnstore indexes
6
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Technologies:
Storage
• Data is stored in a compressed columnar data format (stored by column) instead of row store format (stored by row).
• Columnar storage allows for less data to be accessed when only a sub-set of columns are referenced
New “batch mode” execution
• Data can then be processed in batches (1,000 row blocks) versus row-by-row
• Depending on filtering and other factors, a query may also benefit by “segment elimination” - bypassing million row chunks (segments) of data, further reducing I/O
Columnstore indexes
7
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
When to use it
Table candidates:
• Very large fact tables (for example – billions of rows)
• Larger dimension tables (millions of rows) with compression friendly column data
Query candidates (against table with a columnstore index):
• Scan versus seek (columnstore indexes don’t support seek operations)
• Sub-set of columns (being selective in columns versus returning ALL columns)
• Single-column joins between columnstore indexed table and other tables
Columnstore indexes
8
itcampro @ itcamp12 # Premium conference on Microsoft technologies
MICROSOFT SQL SERVER DATA TOOLS
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
SQL Server Data Tools (SSDT)
• Formerly known as SQL Server Developer Tools, Code-Named “Juneau”.
• SSDT is an evolution of the Visual Studio for Database Professionals ("Data Dude").
• Development tool for the SQL Server and SQL Azure Database Developer.
• Can be installed standalone or can be integrated into an existing Visual Studio 2010 installation (Pro and above).
• It will also ship with the next major release of Visual Studio (Visual Studio 2011).
Microsoft SQL Server Data Tools
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Features
• Targets SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 and SQL Azure
• Migrate on-premise SQL Server schemas to the cloud on SQL
• SQL CLR Development
• Rich disconnected (project-based) development model – Code analysis
– Dependency tracking
– Refactoring
– Intellisense
• Connected model
• Data-tier Application (DAC Fx) model – Script generation also possible
Microsoft SQL Server Data Tools
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Microsoft SQL Server Data Tools
• Single project can target multiple platforms − SQL Server versions
− SQL Azure
• Project build provides errors/warnings − Specific to target
− No need to create and execute scripts to find issues
PLATFORM TARGETING
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Microsoft SQL Server Data Tools
SSDT supports adding SQL CLR objects to database projects
−No need for separate SQL CLR projects
−C# and VB
−Seamless debugging and deployment
−SQLCLR properties tabs on database projects
−Separate projects still supported
SQL Server Data Tools SQL CLR Support
itcampro @ itcamp12 # Premium conference on Microsoft technologies
SQL SERVER EXPRESS LOCALDB
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• SQL Server edition aimed at developers – User-mode, in process execution
– Zero configuration installation
– Transparent database engine for embedding in applications
– Minimal pre-requisites
– Minimal files copied during deployment
– Designed for use in multiple environments
– Used as a test platform for developers
– Embedded database for production applications
– SQLLocalDB.exe utility for management
– Replaces user instance support in SQL Express
– SQL Express user instance support deprecated since SQL Server 2008
– Supports AttachDBFileName in connection string
– Specify location of database files
SQL Server Express LocalDB
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• Similar to working with other editions
– Same SQLServr.exe executable
– Same client-side providers
– Same T-SQL
• Installed once per version per machine
– Applications each launch their own copies of exe
• No services are installed
– Processes started/stopped automatically as needed
– Applications connect to "Data Source=(localdb)/v11.0"
– LocalDB launched as a child process of the application
– LocalDB process shuts down a few minutes after last connection drops
SQL Server Express LocalDB
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server Express LocalDB
Feature SQL Server Compact 3.5 SP2
SQL Server Compact 4.0
SQL Server Express 2012
SQL Server 2012 LocalDB
Deployment/Installation Features
Installation size 2.5 MB download size 12 MB expanded on disk
2.5 MB download size 18 MB expanded on disk
120 MB download size > 300 MB expanded on disk
32 MB download size > 160 MB on disk
ClickOnce deployment Yes Yes Yes Yes
Privately installed, embedded, with the application
Yes Yes No No
64-bit support Yes Yes Yes Yes
Runs as a service No – In process with application
No - In process with application
Yes No – as launched process
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server Express LocalDB
Feature SQL Server Compact 3.5 SP2
SQL Server Compact 4.0
SQL Server Express 2012
SQL Server 2012 LocalDB
Data file features
File format Single file Single file Multiple files Multiple files
Data file storage on a network share
No No No No
Support for different file extensions
Yes Yes No No
Database size support 4 GB 4 GB 10 GB 10 GB
XML storage Yes – stored as ntext
Yes - stored as ntext
Yes Yes
Binary (BLOB) storage Yes – stored as image
Yes - stored as image
Yes Yes
FILESTREAM support No No Yes No
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server Express LocalDB Feature SQL Server
Compact 3.5 SP2 SQL Server Compact 4.0
SQL Server Express 2012
SQL Server 2012 LocalDB
Programmability
Procedural T-SQL - Select Case, If, features
No No Yes Yes
Simple transactions Yes Yes Yes Yes
Distributed transactions
No No Yes Yes
Native XML, XQuery/XPath
No No Yes Yes
Stored procedures, views, triggers
No No Yes Yes
Role-based security No No Yes Yes
Number of concurrent connections
256 (100) 256 Unlimited Unlimited (but only local)
itcampro @ itcamp12 # Premium conference on Microsoft technologies
T-SQL IMPROVEMENTS
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• Query Pagination
• OVER Clause Windowing
• Sequences
• Metadata Discovery
• Enhanced Function Library
• Service Broker Enhancements
• General T-SQL-Related Enhancements
T-SQL improvements
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Query Pagination Syntax:
Example:
T-SQL improvements
SELECT ProductID, Name,Color, Size FROM Production.Product ORDER BY Color,ProductID ASC OFFSET 100 ROWS FETCH NEXT 25 ROWS ONLY; END;
OFFSET <offset_value> ROW|ROWS FETCH FIRST|NEXT <fetch_value> ROW|ROWS [ONLY]
itcampro @ itcamp12 # Premium conference on Microsoft technologies
EXTENDED EVENTS ENHANCEMENTS
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Extended Events
• A general event-handling system for server systems.
• It allows defining events to be monitored and provides a variety of ways to consume the events.
• It can be synchronous or asynchronous (events are fired synchronously).
• It can trigger actions when an event fires.
• It uses predicates to filter events from consumers.
• It has high performance and good scalability.
• The cost of firing a single event is extremely small (approximately 2 μs CPU time on a 2 GHz processor).
Extended Events enhancements
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Extended Events – what’s new
• Management Studio provides support for Extended Events
under the Management folder in Object Explorer
– Target data can be read using the data viewer in Management Studio
• NumberOfEventsMonitored+=hundreds (compared to SQL
Server 2008)
• Management API for .NET Extended Events support
Extended Events enhancements
QueryableXEventData stream = new QueryableXEventData(
@"Data Source = (local); Initial Catalog =
master; Integrated Security = SSPI",
"system_health",
EventStreamSourceOptions.EventStream,
EventStreamCacheOptions.DoNotCache);
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Example
Extended Events enhancements
DECLARE @dbid int = db_id('AdventureWorksDW2008') DECLARE @sql nvarchar(1024) = 'CREATE event session LockCounts ON SERVER
ADD EVENT sqlserver.lock_acquired (WHERE database_id =' + CAST(@dbid AS nvarchar) +')
ADD TARGET package0.synchronous_bucketizer (
SET filtering_event_name=''sqlserver.lock_acquired'', source_type=0, source=''resource_0'')'; EXEC (@sql); GO ALTER EVENT session LockCounts ON SERVER STATE=start; GO
EVENT
TARGET
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Example
Extended Events enhancements
SELECT name, object_id, lock_count FROM (SELECT objstats.value('.','bigint') AS lobject_id, objstats.value('@count', 'bigint') AS lock_count FROM ( SELECT CAST(xest.target_data AS XML) LockData FROM sys.dm_xe_session_targets xest JOIN sys.dm_xe_sessions xes ON xes.address = xest.event_session_address JOIN sys.server_event_sessions ses ON xes.name = ses.name WHERE xest.target_name = 'synchronous_bucketizer' AND xes.name = 'LockCounts' ) Locks CROSS APPLY LockData.nodes('//BucketizerTarget/Slot') AS T(objstats) ) LockedObjects INNER JOIN sys.objects o ON LockedObjects.lobject_id = o.object_id WHERE o.type != 'S' AND o.type = 'U' ORDER BY lock_count desc;
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
Example
Extended Events enhancements
-- -- Stop the event session. -- ALTER EVENT SESSION LockCounts ON SERVER state=stop; GO
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
If a picture is worth a thousand words …
… a 5 minute demo is worth ???
150.000 words
(using the assumption that the human eye
need at least 500 fps to perceive reality without
any distortion)
Extended Events enhancements
itcampro @ itcamp12 # Premium conference on Microsoft technologies
SQL SERVER 2012 CERTIFICATION
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server 2012 certification
• MCSA - Microsoft Certified Solutions Associate
• MCSE - Microsoft Certified Solutions Expert
• MCSD - Microsoft Certified Solutions Developer
• MTA - Microsoft Technology Associate
• MCSM – Microsoft Certfied Solutions Master
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server 2012 certification
Master
Expert
Associate
Microsoft
Certifications
Microsoft Cloud-
built
Certifications
MCM (Master) MCSM
(Solutions
Master)
MCITP (IT
Professional)
MCPD
(Professional
Developer)
MCSE (Solutions
Expert)
MCSD
(Solutions
Developer)
MCTS
(Technology
Specialist)
MCSA (Solutions
Associate)
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development SQL Server 2012 certification
Warning:
You can complete your MCITP or MCTS on SQL
Server 2008 until July 2013
itcampro @ itcamp12 # Premium conference on Microsoft technologies
NEXT STEPS
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Mobile &
Development
• SQL Server 2012 Update for Developers
Training Workshop http://bit.ly/sql2012ro
• SQL Server Virtual Labs
http://www.microsoft.com/sqlserver/en/us/le
arning-center/virtual-labs.aspx
• Migrating from SQL Trace to Extended Events
Mike Wachal’s Blog
• ROSQL http://sqlserver.ro
Next Steps
itcampro @ itcamp12 # Premium conference on Microsoft technologies
Q & A