+ All Categories
Home > Documents > Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open...

Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open...

Date post: 03-Jan-2016
Category:
Upload: byron-walton
View: 221 times
Download: 0 times
Share this document with a friend
Popular Tags:
44
SQL2008 for Developers Meinrad Weiss Principal Consultant Trivadis AG
Transcript
Page 1: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

SQL2008 for Developers

Meinrad WeissPrincipal ConsultantTrivadis AG

Page 2: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Trivadis Solution Portfolio

Core technologies Microsoft, Oracle, IBM, Open Source

Core systems

Individualapplications

(SCM, ERP, CRM)

BusinessIntelligenc

eBusiness

Communicati

on

App

licat

ion

Perf

orm

ance

Man

agem

ent

Ap

plica

tion

Develo

pm

en

t

ManagedServices

Security

Train

ing

Page 3: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Trivadis Facts & Figures

Currently 12 locations with over 500 employeesBaden, Basel, Bern, Lausanne, Zurich Düsseldorf, Frankfurt, Freiburg, Hamburg, Munich, Stuttgart Vienna

Financially independent and sustainably profitable

Key figures in 2007Consolidated income: CHF 98 million / EUR 60 millionOver 1‘500 projects with more than 600 clientsOver 125 Service Level AgreementsAbout 5'000 training participants per year Research budget: CHF 6 million / EUR 3.6 million

Page 4: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Agenda

Simplify existing scenarios

Features for new scenarios

Just profit andInfrastructure

Star Join QueryTransparent Data EncryptionResource Governor

Date Types Table Type ParametersMerge StatementGrouping SetsSparse Columns

Spatial TypeFileStream Type

Page 5: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing

Fact Table

Dimension 1

Dimension 2

Dimension 3

Dimension 4Sum (Amount) of red Productsin Basel

Page 6: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing (2)

Fact Table Scan

Customer Dim Hash Join

Hash Join

Product Dim

Page 7: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing (3)

Fact Table Scan

Customer Dim Hash Join

Hash Join

Product Dim

SQL Server 2005can create one

bitmap filter

Bitmap Filter 1“red”

Page 8: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing (4)

Fact Table Scan

Customer Dim Hash Join

Hash Join

Product Dim

SQL Server 2008can create multiple

bitmap filtersBitmap Filter 2“Basel”

Bitmap Filter 1“red”

Page 9: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing (5)

Fact Table Scan

Customer Dim Hash Join

Hash Join

Product Dim

SQL Server 2008can move and

reorder the filters

Bitmap Filter 2“Basel”

Implemented as Bloom filter http://en.wikipedia.org/wiki/Bloom_filter

The filters can be pushed down into the fact table scan and eliminate almost all the rows that would be eliminated later by the joins

Bitmap Filter 1“red”

Page 10: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Star Join Query Processing (6)

Enterprise Edition FeatureWorks only on parallel plans

FK relationship must be (Trivadis best practices)

One AttributeNot null, Int/Big Int is preferred

In row optimization, Filter is applied during read of phys. Scan

-3x

-2x-5

0%-4

0%-3

0%-2

0%-1

0%Sa

me

10%

20%

30%

40%

50% 2x 3x

0

5

10

15

20

25

30

“Project REAL”

11 Queries Slower

24 Queries Faster

Source: “Christian Kleinerman Microsoft”

Page 11: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Agenda

Simplify existing scenarios

Features for new scenarios

Just profit andInfrastructure

Star Join QueryTransparent Data EncryptionResource Governor

Date Types Table Type ParametersMerge StatementGrouping SetsSparse Columns

Spatial TypeFileStream Type

Page 12: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

New Date Data Types

Simplified programming (date, time) Require less resources

SQL Server Max Precision Range ADO.NET

date 1 day 0001-01-01 to 9999-12-31 DateTime

time 100 nanosec 00:00:00 to 23:59:59.9999999

TimeSpan

datetime2 100 nanosec 1-1-1 to 9999-12-31 DateTime

datetimeoffset

100 nanosec 1-1-1 to 9999-12-31 +/-14:00

DateTimeOffset

More functionality (datetime2, datetimeoffset)

Higher precisionTime zone awareness

Page 13: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Date simple, efficient and fast

Allocates only 3 Bytes(instead of 8 Bytes

datetime)

Convert or Cast will prevent any use of an

index

Page 14: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

DateTime, Date and Time

Page 15: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Merge

DML statement combining multiple operations into one

Both sides can be a table or a view

source targetMerge

Match: UPDATE

No Match: INSERT

No Source Match: DELETE

XYZ XYZ

Page 16: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Merge

MERGE Stock S

USING Trades T ON S.Stock_ID = T.Stock_ID

WHEN MATCHED AND (Qty + Delta = 0) THEN DELETE -- delete stock if Qty reaches 0

WHEN MATCHED THEN -- delete takes precedence over update

UPDATE SET Qty += Delta

WHEN NOT MATCHED THEN INSERT VALUES (Stock, Delta)

OUTPUT $action, T.Stock, inserted.Delta;

Page 17: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

User-Defined Table Types

A user-defined type represents the definition of a table structureIs used to

Declare table-valued parameters for stored procedures or functionsDeclare table variables

Page 18: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Table-valued Parameter

New parameter type for Stored Procedures and Functions

Data are passed by reference to avoid overhead of a copy

Must be passed as Read-Only Parameters

Replace often temp tablesLess overhead and Cleaner DesignCan be used in select from

RestrictionsNo column statisticsCannot be used in Select Into

Page 19: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Table-valued Parameter (2)

Page 20: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Excellent .Net Client Support

Page 21: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Grouping Sets

One query that produces Multiple groupingsReturns a single result set

Result set is equivalent to a UNION ALL of differently grouped rowsSimplifies writing reports with multiple groupings With improved query performance

Page 22: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Grouping Set (2)select DimDate.calendaryear as Year ,DimDate.calendarquarter as Quarter ,DimTerritory.salesterritorycountry as Country ,sum(FactSales.salesamount) as SalesAmountfrom dbo.factresellersales FactSales inner join dbo.dimtime DimDate on FactSales.orderdatekey = DimDate.timekeyinner join dbo.dimsalesterritory DimTerritory on FactSales.salesterritorykey = DimTerritory.salesterritorykey where DimDate.calendaryear in (2003,2004) group by grouping sets ((calendaryear, calendarquarter, salesterritorycountry) ,(calendaryear, calendarquarter) ,())order by DimDate.calendaryear, DimDate.calendarquarter, DimTerritory.salesterritorycountry

Page 23: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sparse Columns & Filtered Indexes

Property Bag Scenarios:Distinct Customized property sets associated with data

Property Name, Value pairsLarge number of unique properties, user annotationsExamples

Content/collaboration systems, Content storesShare Point Server, Documentum

Databases with heterogeneous Record Types in one Table

Type specific properties, inherited properties in a type hierarchyExamples

Product Catalogs (commerce Server, Amazon) Location/business specific properties(Virtual Earth)

Page 24: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sparse Column (1)

Simple implementation of class hierarchies in relational tables

create table Person(ID int not null primary key ,Name varchar(255) not null,BirthDay Date not null,[Type] varchar(25) not null ,Salary money sparse,Department varchar(25) sparse,Rating varchar(2) sparse,LastContact Date sparse )

,...,LastContact Date sparse ,TypeProperties XML COLUMN_SET FOR ALL_SPARSE_COLUMNS)

Page 25: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sparse Column Details

0 Bytes stored for NULL Values~20% CPU overhead for non-null value access Additional 2- 4 bytes for non-null values

Sparse columns are beneficial when space savings >40%Tables can support large number of sparse columns

30K columns, 1K indexes, 30K statisticsRequires the presence/addition of a sparse column set when # of columns >1024

Select * will return all non-sparse columns + sparse_column_ set

Certain types of columns can not be marked as sparse

Computed columns UDT IdentityRowGuidFileStream etc

Page 26: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sparse Column (3)

select *from PersonWithout_COLUMN_SET

select *from Person

select ID, Name, BirthDay, [Type], Salary, Department, Rating, LastContact from Person

Page 27: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Filtered Indexes with regular table

Size

TraditionalIndex

US

FR

CHFL………

This Index will never be used

for ‘US‘, 'FR‘, … queries

Not selective enough

CHFL……

Index Nationality

<> 'US', 'FR'

Filtered Index

Table

Page 28: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Agenda

Simplify existing scenarios

Features for new scenarios

Just profit andInfrastructure

Star Join QueryTransparent Data EncryptionResource Governor

Date Types Table Type ParametersMerge StatementGrouping SetsSparse Columns

Spatial TypeFileStream Type

Page 29: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Spatial Data Types

geography data type• Geodetic (“Round Earth”)

geospatial model• Define points, lines, and areas

with longitude and latitude• Account for planetary

curvature and obtain accurate “great circle” distances

geometry data type• Planar (“Flat Earth”)

geospatial model• Define points, lines, and

areas with coordinates• Use for localized areas or

non-projected surfaces such as interior spaces

2D Vector Support in SQL Server 2008

Page 30: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Spatial Data Types (2)

Implemented as large CLR user-defined type (UDT)

Methods for computingSTGeomFromText('LINESTRING (100 250, 150 100)', 0)STIntersection(<Spatial Object>)STIntersects(<Spatial Object>)…

SQLServer: Geometry, Geography.Net: SqlGeometry, SqlGeography

Geometry Following Open Geospatial Consortium Simple features for SQL

(OGC/SQL MM, ISO 19125)

Page 31: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sample

Page 32: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Sample (2)

Page 33: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Spatial Data Multi-Level Grid Indexes

4.2.3

Page 34: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Index on Spatial Types

Requires Clustered unique index on table

id geometry

1 g1

2 g2

3 g3

Base Table T Internal Table for Indexid cell_id

1 7

3 7

3 8

3 9

3 10

1 13

2 20

Page 35: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

FileStream

ID: 123Name: HansAge: 32

Mixed (Database + Filesystem)

BLOB in Database

FileStream

ID: 123Name: HansAge: 32

ID: 123Name: HansAge: 32

CheapStreaming PerformanceSynchronizationDouble Management

Integrated ManagementTransact. ConsistencySize Limits (2 GB)Heavy load on Log File

Integrated ManagementTransact. ConsistencyStreaming SupportRead Committed Isolation

Page 36: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

FileStream (2)

Unstructured data stored directly in the file system

Requires NTFS

Dual Programming ModelTSQL (Same as SQL BLOB)Win32 Streaming APIs with T-SQL transactional semantics

Data ConsistencyIntegrated Manageability

Back Up / RestoreAdministration e.g. Security

Size limit is the file system volume size

Page 37: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Dual Interface

Begin Transactionselect Get_FileStream_transaction_context() as TxCtx ,PERS_CV.PathName() as UNCPathfrom Person

The Keys to the Win32 Interface

Page 38: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

FileStream

Win32 Applicatio

n

IOManage

r

Rdr Srv

SQL Server FS Agent

NTFS

Client SQL Server 2008User Mode

IO Manage

r

SQL Server FS Driver

Kernel Mode

Active Transaction

TxCtx

Page 39: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Performance

Page 40: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

FileStream Limitations

Failover clusteringFileStream Filegroups must be put on a shared disk

Some Replication LimitsSee http://msdn2.microsoft.com/en-us/library/bb895334(SQL.100).aspx

SQL Server does not support database snapshots for FileStream data files

Rest of the database can be ‘snapshoted’Database mirroring does not support FileStream

Log Shipping is supported ;-)

Page 41: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

FileStream

Don’t forget your DBAInsert, Update and Delete operations have minimal impact on Transaction Log File of DBBut they will affect the size (and time) of Backups

Both Database and TX-Log Backups

FileStream Data can only be stored on “local” Server drivesNever loose the FileStream Data drive

If you loose it then you have the choice between

A probably inconsistent DatabaseLost Transactions

Page 42: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

Conclusion

SQL Server 2008 has many improvements for Developers (and also BI and DBA)Simplify existing work

ProductivityOpen the door for new scenarios

Beyond relationalImprove Security and ReliabilityThe new features are already very stable and well documented

“Es git en heisse Summer hür, …”

Page 43: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

More Infos

Trivadis TechnoCircleSQL Server 2008:

Was ist neu und relevant für DBA’s und IT ProfessionalsDie essentiellen Neuerungen für EntwicklerDas Herz einer modernen Business Intelligence Plattform

Next Generation Data Centric Applications with Visual Studio 2008 and SQL Server 2008

Mit Buchtaufe von Christian Nagel

Demo an unserem StandWPF goes Windows Trivadis FrameworkDatenbank-Setup “Best Practices” und “SharePoint’s Umsetzung”

Wettbewerb und Gutschein

Page 44: Meinrad Weiss Principal Consultant Trivadis AG. Core technologies Microsoft, Oracle, IBM, Open Source Core systems Individual applications (SCM, ERP,

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Recommended