34
Introduction to Columnstore Indexes

Introduction to Columnstore Indexes

Embed Size (px)

DESCRIPTION

Columnstore indexes were first introduced in SQL Server 2012. Columnstore indexes provide the ability to flip-over your indexes from column-based to row-based, leading to dramatic changes in the storage and performance of your data. In this session, we'll review the basic concepts of columnstore indexes and look at the changes coming to them in SQL Server 2014

Citation preview

Page 1: Introduction to Columnstore Indexes

Introduction to Columnstore Indexes

Page 2: Introduction to Columnstore Indexes

Jason Strate

e: [email protected]

e: [email protected]

b: www.jasonstrate.com

t: StrateSQL

Resources jasonstrate.com/go/indexing

Introduction

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 3: Introduction to Columnstore Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

• Industry leaders in Microsoft BI and SQL Server Platform

• SQL Server Professionals - PASS Board of Directors, Speakers, Authors and MVP’s

• National Sales Team Divided by Microsoft Territories

• National System Integrator (NSI)• Gold Certified in Business Intelligence and Data

Platform• Platform Modernization/Safe Passage• Premier Partner for PDW SI Partner Program

MS PDW Partner of Year FY13Frontline Partnership Partner of the Year for Big DataExecutive sponsor - Andy Mouacdie, WW sales director PDW

• Over 7,200 customers worldwide• Over 186,000 people in PW database for demand

generation

About Pragmatic Works

Page 4: Introduction to Columnstore Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Everyone wants fast queries

Page 5: Introduction to Columnstore Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Sometimes Normal Doesn’t Make Sense

Page 6: Introduction to Columnstore Indexes

We need to change what we do

Page 7: Introduction to Columnstore Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

To get things back to normal

Page 8: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 9: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 10: Introduction to Columnstore Indexes

Session Goals

• Identify differences between rowstore and columnstore indexes

• Describe implementation of columnstore index in SQL Server

• Define pros and cons with columnstore indexes

• Demonstrate use of columnstore indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 11: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 12: Introduction to Columnstore Indexes

Index Problems

• Indexes traditionally are row-based

– All columns for row stored together

• Any column read brings over all columns

– Impacts IO, CPU, and memory

– Typically 15% of DW columns in queries

• Databases growing 10x every 5 years

• Tuning for over indexing, under indexing, and bookmark lookups

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 13: Introduction to Columnstore Indexes

Columnstore Basics

• Change data storage from row to column based

– Rowstores

– Columnstores

• Data grouped by columns

– One column per grouping (segment)

– Data access at columns level

– Only return columns required for query

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 14: Introduction to Columnstore Indexes

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Say What?!

Page 15: Introduction to Columnstore Indexes

Traditional Index

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 16: Introduction to Columnstore Indexes

Columnstore Index

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 17: Introduction to Columnstore Indexes

Columnstore Index

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 18: Introduction to Columnstore Indexes

Why Columnstore?

• Improved query performance

– Column centric reads

– Heavy data compression

– Processing by batch versus row

• Improved resource utilization

– Smaller index space

– Less memory required

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 19: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 20: Introduction to Columnstore Indexes

SQL Server Columnstore

• Introduced to improve data warehouse performance

• Available since SQL Server 2012

• SQL Server 2012

– Non-clustered columnstore

• SQL Server 2014

– Clustered columnstore

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 21: Introduction to Columnstore Indexes

Columnstore Attributes

• Introduced in SQL Server 2012• Supports batch mode processing• SQL Server 2012

– Non-clustered columnstore– No key columns– Support partitioning– Read only index

• SQL Server 2014– Clustered columnstore– Columnstore archive format– Read\write when clustered

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 22: Introduction to Columnstore Indexes

Batch-mode Processing

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

1 record versus 415 records

Page 23: Introduction to Columnstore Indexes

Columnstore Restrictions

• Cannot be a unique index.• Cannot be created on a view or

indexed view.• Cannot include a sparse

column.• Cannot act as a primary key or

a foreign key.• Cannot be created with

the INCLUDE keyword• Cannot include

the ASC or DESC keywords for sorting the index

• No seek operations

• Cannot contain a column with a FILESTREAM attribute

• Limited data types– Except varchar(max),

nvarchar(max), binary, varbinary, ntext, text, image, uniqueidentifier, rowversion, timestamp, sqlvariant, xml, CLR types

• Feature restrictions– Replication– Change tracking– Change data capture– Filestream

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 24: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 25: Introduction to Columnstore Indexes

Non-Clustered Columnstore

• Available in:– SQL Server 2012– SQL Server 2012 Parallel Data Warehouse– SQL Server 2014

• One non-clustered columnstore per table– Support tables heap or clustered index

• Add in all columns from table– No key columns

• Best support star-join style queries• Avoid OUTER JOIN and NOT IN

– Prevent batch processing

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 26: Introduction to Columnstore Indexes

Updating Non-Clustered Columnstore

• Drop the columnstore

• Perform DML

• Recreate columnstore

Drop and Rebuild

• Create new partition with modified data

• Create columnstore

• Switch in partition

Partition Switch

• Apply changes to separate table

• UNION ALL columnstore or change table

• Manage DML through trigger

Partitioned View

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 27: Introduction to Columnstore Indexes

NON-CLUSTERED COLUMNSTORE

Demo

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 28: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 29: Introduction to Columnstore Indexes

Clustered Columnstore

• Available in:– SQL Server 2012 Parallel Data Warehouse

– SQL Server 2014

• One clustered columnstore per table– Is primary storage for data

– Reduces space requirements

• Can leverage columnstore archive format

• Same design patterns as non-clustered

• Preferred over non-clustered columnstore

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 30: Introduction to Columnstore Indexes

CLUSTERED COLUMNSTORE

Demo

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 31: Introduction to Columnstore Indexes

Agenda

Introduction Columnstore BasicsSQL Server

Columnstore

Non-Clustered Columnstore

Clustered Columnstore

Summary

Page 32: Introduction to Columnstore Indexes

Summary

• Columnstore indexes change data can be accessed

• Provides increased data compression

• Retrieves only the columns that are needed

• Primary benefit in data warehouses

– Slowly or unchanging data

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 33: Introduction to Columnstore Indexes

More Information

Expert Performance IndexingFor SQL Server 2012

Jason StrateTed Krueger

OverviewStatistics

MaintenanceTools

Analysis

http://amzn.com/1430237414

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 34: Introduction to Columnstore Indexes

ServicesSpeed development through training, and rapid development services from Pragmatic Works.

ProductsBI products to covert to a Microsoft BI platform and simplify development onthe platform.

FoundationHelping those who do not have themeans to get into information technologyachieve their dreams.

For more information…Name: Jason Strate

Email: [email protected]

Blog: www.jasonstrate.com

Resource: jasonstrate.com/go/indexing

Need Help? jasonstrate.com/go/vmdba