Practical uses of new T-SQL functionality in SQL Server 2012 & Windows Azure SQL Database.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008.
SQL/PL SQL Oracle By Rana Umer. Performance Tuning Indexes ROWID View Sequences Oracle By Rana Umer.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
End of SQL: Triggers, Impedance Mismatch and Transactions February 6 th, 2004.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Practical Uses and Optimization of New T-SQL Features in Microsoft SQL Server 2012 Tobias Ternstrom DBI308.
Distributed Databases
2015 International TechNet Wiki Summit 2015 Saeid Hasani Structured Error Handling Mechanism in SQL Server 2012 & 2014.
IST Databases and DBMSs Todd S. Bacastow January 2005.
Databases with Scalable capabilities Presented by Mike Trischetta.
Training Workshop Windows Azure Platform. Presentation Outline (hidden slide): Technical Level: 200 Intended Audience: Developers Objectives (what do.
A Comedy of Errors Handling Errors in T-SQL Code Andrew Whettam.
Organizing Information Digitally Norm Friesen. Overview General properties of digital information Relational: tabular & linked Object-Oriented: inheritance.
Module 12 Handling Errors in T-SQL Code. Module Overview Understanding T-SQL Error Handling Implementing T-SQL Error Handling Implementing Structured.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Chapter 6 Additional Database Objects
WHAT SEQUENCE OBJECTS ARE (AND ARE NOT) Louis Davidson Data Architect.
BARBARIN DAVID SQL Server Senior Consultant Pragmantic SQL Server Denali : New development features.
CODD’s 12 RULES OF RELATIONAL DATABASE
Stored Procedures, Transactions, and Error-Handling
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Chapter 5 Sequences.
Advanced SQL Advanced SQL Complex Queries, Joining Tables.
WHAT SEQUENCE OBJECTS ARE (and are not) Presentation by Louis Davidson
Database Programming Sections 11 & 12 – Creating, and Managing Views, Sequences, Indexes, and Synonymns.
Improving Database Performance Derrick Rapley
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
What’s New In Denali - TSQL David Ballantyne. Who am I Kent.Net/SqlServer.
DBI318. SQL Server RDBMS Team Connectivity App Platform T-SQL Language, Data-Tier Application Model, Types, Libraries SQL Engine High Availability Mirroring,
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Transactions and Locks A Quick Reference and Summary BIT 275.
Windows Role-Based Access Control Longhorn Update
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
06 | Modifying Data in SQL Server Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
RDBMS MySQL. MySQL is a Relational Database Management System MySQL allows multiple tables to be related to each other. Similar to a Grandparent to a.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
SQL ACTION QUERIES AND TRANSACTION CONTROL CS 260 Database Systems.
Database Basics BCIS 3680 Enterprise Programming.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
A SParqly Jython++ A SParqly Jython++ an ASP/SPARQL enhanced Jython Cliff Cheng Carlos Urrutia Francisco Garcia.
Dynamo: Amazon’s Highly Available Key-value Store DAAS – Database as a service.
SQL:2003 An Introduction to Some New Features. New Data Types BIT and BIT VARYING removed BIGINT, MULTISET and XML introduced –First class data types:
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Database Programming Sections 12 – Sequences, Indexes, and Synonymns.
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
Lock Tuning. Overview Data definition language (DDL) statements are considered harmful DDL is the language used to access and manipulate catalog or metadata.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Database Management System Architecture 2004, Spring Pusan National University.
PHP AND SQL SERVER: QUERIES IST 210: Organization of Data IST210 1.
Chapter 8 Advanced SQL. Relational Set Operators UNIONINTERSECTMINUS Work properly if relations are union- compatible –Names of relation attributes must.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
SQL Basics Review Reviewing what we’ve learned so far…….
11 | Error Handling and Transactions
What is New for T-SQL in SQL Server 2012 & SQL Azure
Optimizing Microsoft SQL Server 2008 Applications Using Table Valued Parameters, XML, and MERGE
ISC440: Web Programming 2 Server-side Scripting PHP 3
On transactions, and Atomic Operations
Jan Engelsberg Program Manager, SQL Server
Chapter 5 Sequences.
Fundamentals of Databases
On transactions, and Atomic Operations
HAVING,INDEX,COMMIT & ROLLBACK
Опит в използването на ODP.NET с Oracle 9i
Improving the Performance of Functions
Presentation transcript:

Practical uses of new T-SQL functionality in SQL Server 2012 & Windows Azure SQL Database

CREATE SEQUENCE [ schema_name. ] sequence_name [ AS { } ] [ START WITH ] [ INCREMENT BY ] [ MINVALUE | NO MINVALUE ] [ MAXVALUE | NO MAXVALUE ] [ CYCLE | NO CYCLE ] [ CACHE [ ] | NO CACHE ] NEXT VALUE FOR [ schema_name. ] sequence_name [ OVER ( ) ] EXEC sp_sequence_get_range …

Guaranteed to be globally unique Can be made sequential Caveats! Really hard to guess… (when not sequential) Use any data type for keys (for ex. strings) Can guarantee a continuous range of values (no wholes) Including ranges Serializes number generation across transactions Supports all integer types, starting from TINYINT up to DECIMAL(38, 0) Supports range reservation Caching “knob” for performance tuning Large; requires 16 bytes storage Many systems don’t natively support GUIDs Causes fragmentation Sequential generation cannot be guaranteed even with NEWSEQUENTIALID () Access to the identifier is serialized across transactions Performance issue Not native RDBMS functionality, more code Cannot guarantee a continuous range of values E.g. can “lose” values because of dirty shutdowns or rollbacks GUIDs Pros Cons Separate tableSequences

THROW,, ; always aborts the batch Batch aborts if not in SET XACT_ABORT ON where it Transaction-aborts Does not automatically use sys.messages is even spelled correctly! re-THROW BEGIN CATCH …; THROW; END CATCH

Flexible Well known Logs events without sending a message to the client Multiple behaviors, easy to get it wrong Not supported on SQL Database RAISERROR Pros Cons xp_logevent Flexible, supports the attributes you specify Transactions need to be managed so log records are not rolled back Logging table Easy to use Similar behavior to other programming languages Re-throw capabilities Less flexible than RAISERROR THROW

TranIdAccountIdTranDateAmount

3 trn. avg. TranIdAccountIdTranDateAmount The FRAME Window PARTITION The FRAME Window FRAME

BalanceTranIdAccountIdTranDateAmount Window PARTITIONs The FRAME Window FRAME

Approach that is commonly used in other programming languages Follows the SQL set based paradigm Improved optimization Easy to write Following the SQL set based paradigm Not set based Only individual queries are optimized, not the operation as a whole Many lines of code  Higher risk for bugs Bad performance due to plan with N 2 complexity solution Non-trivial to write Not always the optimal solution Not all queries can be easily rewritten to leverage window functions Imperative approach Pros Cons Correlated sub queriesWindow Functions

SELECT... ORDER BY... OFFSET ROWS FETCH NEXT ROWS ONLY EXECUTE [WITH [,...n ]] { RESULT SETS {UNDEFINED|NONE|( )} } ::= { | AS OBJECT [.] {table_name | view_name | tvf} | AS TYPE [schema_name.]table_type_name | AS FOR XML | (…) [,...n ]}

Questions?