fundamentos de indices en sql server - enrrique puig

Post on 01-Jul-2015

210 Views

Category:

Data & Analytics

13 Downloads

Preview:

Click to see full reader

DESCRIPTION

Los índices son elementos importantísimos a la hora de optimizar consultas. En esta sesión abarcaremos los distintos tipos de índices que existen, veremos como nos ayudan a optimizar consultas y finalmente hablaremos de su mantenimiento.

TRANSCRIPT

Fundamentos sobre los índices en SQL Server

20 de Agosto (12 pm GMT -5)

Enrique PuigResúmen:

Los índices son elementos importantísimos a la

hora de optimizar consultas. En esta sesión

abarcaremos los distintos

tipos de índices que existen, veremos como nos

ayudan a optimizar consultas y finalmente

hablaremos de su mantenimiento..

Próximos Eventos

Indices columnares en SQL Server

2014

10 de Septiembre

José L. Rivera

Visualización de Big Data con

Power View

27 de Agosto

Eduardo Castro

Mejores prácticas de SQL Server

para implementar SharePoint

3 de Septiembre

David Sánchez

Está por comenzar:

Fundamentos sobre los Índices en SQL Server

20/08/2014

Enrique Puig

MAP | MCITP

DBA at RipLife Gaming Technologies

Blog: www.sqlserverpasion.com

Mail: e.puig@Outlook.es

Twitter: @epuignouselles

Objetivos

• Introducción a los Índices

• ¿Qué son?

• ¿Para que sirven?

• ¿Qué tipos de índices existen?

• ¿Cómo ayudan los índices a mejorar el performance?

3

Agenda

• ¿Qué son los índices?

• Introducción

• Heaps

• Índices clustered

• Índices nonclustered

• Conclusiones

• Preguntas

4

¿Qué son los Índices?

5

Introducción

• Gestores de base de datos guardan información (Datos) en

• Tablas / Relaciones

• Conjuntos de datos no ordenados

• Los datos se almacenan en disco

• Unidad de almacenamiento son Paginas de datos (8KB)

6

Introducción (II)

7

Data Page 1 Data Page 2 Data Page 3 Data Page 4 …

dbo.Sales

Heaps

• ´Montón’ de datos no ordenado

• Un Heap es la Tabla

• Contiene los datos

8

Data Data Data Data Data

IAM

Índices clustered

• Estructura de datos: Árbol B

• Estructura de datos ordenada por clave

• El Índice clustered es la tabla

• Contiene todos los datos

• Nodos hoja

• Primary Key by Default

9

Root

Int.

Data Data

Int

Data Data

Heaps vs. Clustered Indexes

10

• Clustered Index

• Datos ordenados

• Acceso a datos rápido (KEY)

• Paginas de datos enlazadas

• Acceso secuencial eficiente

• Heaps

• Datos no ordenados

• Paginas de datos no enlazadas

• Acceso secuencial ineficiente

• Consultas extra a la IAM

• Recomendación: Utilizar Clustered Index

DEMO: Heaps vs. Índices clustered

11

Índices nonclustered

• Estructura auxiliar a la tabla de datos: Árbol B

• Ordenada por Clave del Índice

• Nodos hoja contienen

• Claves de Índice

• Referencia a registro de datos

12

Root

Int.

Key

Ref

Key

Ref

Int

Key

Ref

Key

Ref

Índices nonclustered vs. Clustered

13

Root

Int.

Data Data

Int

Data Data

Root

Int.

Key

Ref

Key

Ref

Int

Key

Ref

Key

Ref

Nonclustered INDEX Clustered INDEX

KEY + Row Reference Data rows

Índices nonclustered con Heaps

• Referencias a Datos

• Row IDentifier (RID)

14

Root

Int.

Key

RID

Key

RID

Int

Key

RID

Key

RID

Data

2

Data

3

Data

4

Data

5

Data

6

Data

7

Data

1

INDEX

HEAP

Índices nonclustered con Clustered Index

• Referencia a Datos

• Clustered Index KEY

15

Root

Int.

Key

cl key

Key

cl key

Int

Key

cl key

Key

cl key

INDEX

Root

Int.

Data Data

Int

Data Data

Clustered Index

DEMO: Índices nonclustered

16

Indices nonclustered de cobertura

• Posibilidad de incluir columnas en Índices

• Acerca datos a los índices

• Nodo Hoja

• Eficiencia vs. Espacio

• Reduce Lookups

17

Root

Int.

Key

Ref

COL1

COL2

Int

Key

Ref

COL1

COL2

Key

Ref

COL1

COL2

Key

Ref

COL1

COL2

DEMO: Índices nonclustered de cobertura

18

Otros tipo de Índices

• Índices nonclustered (Filtrados)

• Índices columnares (New 2014)

• Hash (New 2014 / In-Memory OLTP)

• Menos comunes

• Índices XML

• Índices espaciales (Spatial Indexes)

• Full-Text

19

Conclusiones

• Índices son armas poderosas para acelerar consultas

• Sigue las buenas practicas!!

• Utiliza Clustered Index

• Evitar sobre indexación

• Evitar índices solapados

• Todo tiene un coste

• Mantenimiento de índices con operaciones de escritura

20

¿Preguntas?

21

Blog: www.sqlserverpasion.com

Mail: e.puig@Outlook.es

Twitter: @epuignouselles

Gracias

22

Blog: www.sqlserverpasion.com

Mail: e.puig@Outlook.es

Twitter: @epuignouselles

Manténgase conectado a nosotros!

23

Visítenos en http://globalspanish.sqlpass.org

/SpanishPASSVC

lnkd.in/dtYBzev

/user/SpanishPASSVC

/SpanishPASSVC

PASS Community NewsAugust 2014

Planning on attending PASS Summit 2014? Start saving

today!

• The world’s largest gathering of SQL Server & BI professionals

• Take your SQL Server skills to the next level by learning from the world’s SQL

Server experts, in 190+ technical sessions

• Over 5000 attendees, representing 2000 companies, from 52 countries,

ready to network & learn

Ask your Chapter Leader how to

save $150 off registration!$1,895

UNTIL SEPTEMBER 26, 2014

PASS Virtual Chapters Listing

Check out the sqlpass.org for more information on all the Virtual Chapters:

• Application Development

• Big Data

• Book Readers

• Business Analytics

• Business Intelligence

• Cloud

• Data Architecture

• Database Administration

• DBA Fundamentals

• Excel BI

• Healthcare

• High Availability and Disaster Recovery

• InMemory

• Master Data\Data Quality

• Oracle SQL

• Performance

• Powershell

• Professional Development

• Security

• Virtualization

• Women in Technology

• Global Chinese

• Global French

• Global Hebrew

• Global Italian

• Global Portuguese

• Global Russian

• Global Spanish

Virtual Chapter Meetings – August

VIRTUAL CHAPTER MEETING TOPIC

DBA Fundamentals Aug 5 11:00– 12:00 CDT (UTC -05:00) Rolling Upgraders, The Easy Way

Presented by Argenis Fernandez

Global Spanish Aug 6 12:00-12:30 (UTC -05:00) Los Caso de Uso Para In-Memory OLTP

Presented by Warner Chaves

Global Hebrew Aug 10 17:30-18:30 JDT (UTC +02:00) Take Your SQL Server Development

Process Forward!

Presented by Itai Binyamin

Professional

Development

Aug 12 12:00-13:00 EDT (UTC -04:00) Bridging the Communication Gap

Between DBA and Developer

Presented by Robert Davis

High Availability and

Disaster Recovery

Aug 12 12:00-13:00 CDT (UTC -05:00) Mirroring Start to Finish

Presented by Ryan Adams

Virtual Chapter Meetings – August

VIRTUAL CHAPTER MEETING TOPIC

Global Spanish Aug 13 12:00-13:00 (UTC -05:00) Haciendo Preguntas Básicas en Power

BI

Presented by Andrei Garzon

Excel Business

Intelligence

Aug 14 11:00-12:00 EDT (UTC-04:00) Advanced Analytics: Excel Solver

Presented by Dan Fylstra

Business Intelligence Aug 14 11:00-12:00 EDT (UTC -04:00) Continuous Integration for Reporting

Services

Presented by Nat Sundar

DBA Fundamentals Aug 19 11:00-12:00 CDT (UTC -05:00) The Roadmap to Better Performance:

Reading Query Plans

Presented by Erin Stellato

Global Spanish Aug 20 12:00-12:30 (UTC -05:00) Fundamentos sobre lost indices end

SQL

Presented by Enrique Puig

Virtual Chapter Meetings – August

VIRTUAL CHAPTER MEETING TOPIC

Global Russian Aug 20 15:00-16:30 (UTC +03:00) SSIS - Повышение

производительности обработки

потоков данных

Global French Aug 21 20:00-21:00 RST (UTC +01:00) Power BI Hybride avec la Passerelle de

Gestion de Données

Presented by Jean-Pierre Riehl

Business Analytics Aug 21 12:00-13:00 CDT (UTC -05:00) Looking Through the Windshield:

Creating forward-looking Dashboards

and KPI’s

Presented by Brian Larson

Business Intelligence Aug 27 12:00-13:00 GMT (UTC-00:00) Intro to R

Presented by Stephanie Locke

Global Spanish Aug 27 12:00-13:00 (UTC-05:00) Visualización de Big Data Con Power

View

Presented by Eduardo Castro

Upcoming SQLSaturdays

Upcoming North America Events Upcoming International Events

• Aug 2 #324 Baton Rouge

• Aug 9 #304 Indianapolis

• Aug 23 #328 Birmingham

• Aug 23 #309 Oklahoma City

• Sep 6 #320 Raleigh

• Sep 13 #300 Kansas City

• Sep 20 #331 Denver

• Sept 20 # 340 San Diego

• Aug 30 #327 Johannesburg

• Aug 30 #317 Oslo

• Sep 6 #301 Cape Town

• Sep 13 # 323 Paris

• Sep 20 #290 Kiev

• Sep 20 #310 Dublin

• Sep 27 #325 Sao Paulo

Visit www.sqlsaturday.com to

register for an event near you!

31

Volunteering with PASS

Volunteer Today!

Now it’s easier than ever to volunteer with PASS.

Let us know your volunteer preferences by updating the

“myVolunteering” section of your myPASS profile.

PASS would not exist without our passionate, dedicated,

and hardworking volunteers from around the globe.

32

Outstanding Volunteer Award

Do you know a volunteer that has gone

above and beyond recently?

Nominate them for the monthly OVA.

VolunteerRecognition@sqlpass.org

Volunteering with PASS

PASSion Award

The highest of PASS accolades presented

yearly to a volunteer.

Nominations will open in August 2014.

Stay tuned!

Stay Involved!• Sign up for a free membership today at sqlpass.org

• Linked In: http://www.sqlpass.org/linkedin

• Facebook: http://www.sqlpass.org/facebook

• Twitter: @SQLPASS

• PASS: http://www.sqlpass.org

Programa de Reconocimiento

Programa de Voluntario Sobresaliente

• PASS le invita a nominar a su voluntario favorito para ser “Voluntario Sobresaliente del Mes”

• Enviar nominaciones en todo momento a: VolunteerRecognition@sqlpass.org

Favor proveer:

• Información de contacto del nominado,

• una lista breve de los programas de PASS que a participado el nominado

• los años que lleva activo en la comunidad

• una corta descripción por el cual considera que esta persona debe ser reconocida

• Los nominados seleccionados serán anunciados en la edición del boletín PASS Connectory recibirán un certificado de apreciación.

Visualización de Big Data con Power View

27 de Agosto (12 pm GMT -5)

Eduardo Castro

Resúmen:

En esta sesión veremos ejemplos,de como realizar

análisis de big data con PowerView integrato con

HDInsight y HortonWorks.

Próximo Evento

top related