The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
ITCamp 2012 - Cristi Lefter - SQL Server 2012 for developers
1. SQL Server 2012 for
developers
Cristian Lefter, SQL Server MVP
http://about.me/CristianLefter
@ itcampro # itcamp12 Premium conference on Microsoft technologies
2. ITCamp 2012 sponsors Mobile &
Development
@ itcampro # itcamp12 Premium conference on Microsoft technologies
3. Agenda Mobile &
Development
• Columnstore indexes
• Business Intelligence Development Studio
• SQL Server Express LocalDB
• Transact-SQL improvements
• Extended Events enhancements
• SQL Server 2012 certification
• Next steps
@ itcampro # itcamp12 Premium conference on Microsoft technologies
4. COLUMNSTORE INDEXES
@ itcampro # itcamp12 Premium conference on Microsoft technologies
5. Columnstore indexes Mobile &
Development
Row Store (Heap / B-Tree) Column Store (values compressed)
data page 1000 data page data page data page
ProductID OrderDate Cost
2000 2001 2002
310 20010701 2171.29 ProductID OrderDate Cost
310 20010701 2171.29
311 20010701 1912.15
311 … 1912.15
312 20010702 2171.29 312 20010702 2171.29
313 …
313 20010702 413.14 413.14
314 …
333.42
315 20010703
data page 1001 1295.00
316 …
ProductID OrderDate Cost 4233.14
317 …
314 20010701 333.42 641.22
318 …
319 24.95
315 20010701 1295.00 …
320 20010704 64.32
316 20010702 4233.14
321 … 1111.25 5
317 20010702 641.22
@ itcampro # itcamp12 Premium conference on Microsoft technologies
6. Columnstore indexes 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
6
@ itcampro # itcamp12 Premium conference on Microsoft technologies
7. Columnstore indexes 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
7
@ itcampro # itcamp12 Premium conference on Microsoft technologies
8. Columnstore indexes 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 8
@ itcampro # itcamp12 Premium conference on Microsoft technologies
9. MICROSOFT SQL SERVER DATA
TOOLS
@ itcampro # itcamp12 Premium conference on Microsoft technologies
10. Microsoft SQL Server Data Tools 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).
@ itcampro # itcamp12 Premium conference on Microsoft technologies
11. Microsoft SQL Server Data Tools 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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
12. Microsoft SQL Server Data Tools Mobile &
Development
PLATFORM TARGETING
• 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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
13. Microsoft SQL Server Data Tools Mobile &
Development
SQL Server Data Tools SQL CLR Support
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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
14. SQL SERVER EXPRESS LOCALDB
@ itcampro # itcamp12 Premium conference on Microsoft technologies
15. SQL Server Express LocalDB 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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
16. SQL Server Express LocalDB 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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
17. SQL Server Express LocalDB Mobile &
Development
Feature SQL Server SQL Server SQL Server SQL Server 2012
Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDB
Deployment/Installation Features
Installation size 2.5 MB 2.5 MB 120 MB 32 MB
download size download size download size download
12 MB 18 MB > 300 MB size > 160
expanded on expanded on expanded on MB on disk
disk disk disk
ClickOnce deployment Yes Yes Yes Yes
Privately installed, Yes Yes No No
embedded, with the
application
64-bit support Yes Yes Yes Yes
Runs as a service No – In process No - In process Yes No – as
with application with launched
application process
@ itcampro # itcamp12 Premium conference on Microsoft technologies
18. SQL Server Express LocalDB Mobile &
Development
Feature SQL Server SQL Server SQL Server SQL Server 2012
Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDB
Data file features
File format Single file Single file Multiple files Multiple files
Data file storage on a No No No No
network share
Support for different Yes Yes No No
file extensions
Database size support 4 GB 4 GB 10 GB 10 GB
XML storage Yes – stored as Yes - stored as Yes Yes
ntext ntext
Binary (BLOB) storage Yes – stored as Yes - stored as Yes Yes
image image
FILESTREAM support No No Yes No
@ itcampro # itcamp12 Premium conference on Microsoft technologies
19. SQL Server Express LocalDB Mobile &
Development
Feature SQL Server SQL Server SQL Server SQL Server 2012
Compact 3.5 SP2 Compact 4.0 Express 2012 LocalDB
Programmability
Procedural T-SQL - No No Yes Yes
Select Case, If, features
Simple transactions Yes Yes Yes Yes
Distributed No No Yes Yes
transactions
Native XML, No No Yes Yes
XQuery/XPath
Stored procedures, No No Yes Yes
views, triggers
Role-based security No No Yes Yes
Number of concurrent 256 (100) 256 Unlimited Unlimited
connections (but only
local)
@ itcampro # itcamp12 Premium conference on Microsoft technologies
20. T-SQL IMPROVEMENTS
@ itcampro # itcamp12 Premium conference on Microsoft technologies
21. T-SQL improvements Mobile &
Development
• Query Pagination
• OVER Clause Windowing
• Sequences
• Metadata Discovery
• Enhanced Function Library
• Service Broker Enhancements
• General T-SQL-Related Enhancements
@ itcampro # itcamp12 Premium conference on Microsoft technologies
22. T-SQL improvements Mobile &
Development
Query Pagination
Syntax:
OFFSET <offset_value> ROW|ROWS
FETCH FIRST|NEXT <fetch_value> ROW|ROWS [ONLY]
Example:
SELECT ProductID, Name,Color, Size
FROM Production.Product
ORDER BY Color,ProductID ASC
OFFSET 100 ROWS
FETCH NEXT 25 ROWS ONLY;
END;
@ itcampro # itcamp12 Premium conference on Microsoft technologies
23. EXTENDED EVENTS
ENHANCEMENTS
@ itcampro # itcamp12 Premium conference on Microsoft technologies
24. Extended Events enhancements 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).
@ itcampro # itcamp12 Premium conference on Microsoft technologies
25. Extended Events enhancements 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
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
26. Extended Events enhancements Mobile &
Development
Example
DECLARE @dbid int = db_id('AdventureWorksDW2008')
EVENT
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 ( TARGET
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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
27. Extended Events enhancements Mobile &
Development
Example
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
28. Extended Events enhancements Mobile &
Development
Example
--
-- Stop the event session.
--
ALTER EVENT SESSION LockCounts ON SERVER
state=stop;
GO
@ itcampro # itcamp12 Premium conference on Microsoft technologies
29. Extended Events enhancements 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)
@ itcampro # itcamp12 Premium conference on Microsoft technologies
30. SQL SERVER 2012
CERTIFICATION
@ itcampro # itcamp12 Premium conference on Microsoft technologies
31. SQL Server 2012 certification Mobile &
Development
• 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
32. SQL Server 2012 certification Mobile &
Development
Microsoft Microsoft Cloud-
Certifications built
Certifications
MCM (Master) MCSM
(Solutions
Master)
Master
MCITP (IT MCSE (Solutions
Professional) Expert)
MCPD MCSD
(Professional (Solutions
Expert Developer) Developer)
MCTS MCSA (Solutions
(Technology Associate)
Specialist)
Associate
@ itcampro # itcamp12 Premium conference on Microsoft technologies
33. SQL Server 2012 certification Mobile &
Development
Warning:
You can complete your MCITP or MCTS on SQL
Server 2008 until July 2013
@ itcampro # itcamp12 Premium conference on Microsoft technologies
34. NEXT STEPS
@ itcampro # itcamp12 Premium conference on Microsoft technologies
35. Next Steps 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
@ itcampro # itcamp12 Premium conference on Microsoft technologies
36. Q&A
@ itcampro # itcamp12 Premium conference on Microsoft technologies