In-Memory OLTP en SQL Server 2014
-
Upload
enrique-catala-banuls -
Category
Technology
-
view
488 -
download
2
description
Transcript of In-Memory OLTP en SQL Server 2014
![Page 1: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/1.jpg)
Foro Microsoft Big Data y Analytics
Filtrar > Decidir > AcertarNunca fue más fácil
![Page 2: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/2.jpg)
Nuevo motor relacional In-Memory OLTP en SQL Server 2014
Enrique Catalá Bañuls (@enriquecatala)
MVP – MCT – Mentor en SolidQ
![Page 3: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/3.jpg)
Únete a PASS SpainComunidad Española de SQL Server
• Noticias
• Webcasts
• Charlas
• Foro, dudas…
https://www.facebook.com/PASSspanish
![Page 4: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/4.jpg)
![Page 5: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/5.jpg)
SolidQ Summit Madrid 2014
20, 21, 22 Mayo 2014
• 2 Tracks SQL,BI ,Big Data
• 3 jornadas
• 30 sesiones técnicas
• Mentores de SolidQ
http://summit.solidq.com http://www.gusenet.org
23 charlas variadasBI, SQL, C#, MVC, angular, Javascript, Kinect, NancyFx, Dev, …
![Page 6: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/6.jpg)
Agenda
Motivación
Arquitectura
Uso de In-Memory OLTP
Coexistencia con otras tecnologías
Aplicaciones prácticas
![Page 7: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/7.jpg)
1. Reducir el número de
ciclos por instrucción
2. Mejorar la escalabilidad
(uso de recursos HW
mejor aprovechados)
3. Disminuir el número de
instrucciones ejecutadas
por petición
Aumentar
rendimiento
100x
Motivación
![Page 8: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/8.jpg)
MotivaciónRendimiento por core se apalancaCoste de memoria disminuye
$/GB de Memoria
1
10
100
1.000
10.000
100.000
1.000.000
1990
1991
1992
1993
1994
1994
1995
1996
1997
1998
1999
2000
2000
2001
2002
2004
2005
2007
2008
2009
2011
US$
/GB
0
1
10
100
1.000
10.000
100.000
1.000.000
10.000.000
1970 1975 1980 1985 1990 1995 2000 2005 2010
![Page 9: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/9.jpg)
Motivación: Limitaciones
Tablas on-disk
Page
Latch
![Page 10: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/10.jpg)
Agenda
Motivación
Arquitectura
Uso de In-Memory OLTP
Coexistencia con otras tecnlogías
Aplicaciones prácticas
![Page 11: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/11.jpg)
In-Memory en motor relacional
In-Memory OLTP
• 5-30x rendimiento en OLTP
• Integrado en SQL Server
In-Memory DataWarehouse
• 5-25x rendimiento
• Elevada compression
• Soporta clustered y escrituras
SSD Buffer pool extension
• Mejora transparente
• Hasta 3x rendimiento
Aplicación directa en cargas de trabajo
Entornos OLTP altamente
concurrentes
Entornos BI con DW
grandes y agregaciones
masivas
Entornos transaccionales
sobre OnDisk de grandes
volúmenes de datos
![Page 12: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/12.jpg)
Pilares de In-Memory OLTP
Integracion completa
• T-SQL conocido
• Mismas herramientas
• Integrado
completamente en SQL
Server (sin licencia
extra)
Optimizado para memoria
RAM
• Nuevas estructuras de
almacenamiento
• Sin Buffer Pool
• Punteros a datos
• Todo son índices de
cobertura
Alta concurrencia
• Gestión de concurrencia
optimista multiversion
• Soporte ACID
• Nuevo motor con
algorimos lock-free
• Sin latches
T-SQL supereficiente
• T-SQL compilado a
código máquina en C
• Los SP son DLL
• Compilaciones
superagresivas a código
máquina
![Page 13: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/13.jpg)
Integración
Memory-optimized table
filegroup Data filegroup
SQL Server.exe
In-memory OLTP engine for memory-
optimized tables and indexes
TDS handler and session management
Natively compiled SPs
and schema
Buffer pool for tables and indexes
Proc/plan cache for ad-hoc T-SQL
and SPs
Transaction log
Query interoperabilityNon-durable
table T1 T4T3T2
T1 T4T3T2
T1 T4T3T2
T1 T4T3T2
Tables
Indexes
Interpreter for TSQL, query plans,
expressions
T1 T4T3T2
T1 T4T3T2
Checkpoint and recovery
Access methods
Parser,
Catalog,
Algebrizer,
Optimizer
In-Memory
OLTP Compiler
In-Memory
OLTP
component
Key
Existing SQL
component
Generated .dll
Client app
![Page 14: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/14.jpg)
Ventajas In-Memory
Tablas on-disk
Page
Latch
Tablas in-memory
![Page 15: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/15.jpg)
Concurrencia en In-Memory OLTP
Sin bloqueos
• Sin lock, latches
• Sin deadlocks
• Mínimo context switch
• Requiere gestión de
excepciones
MultiversionadoAlta concurrencia
• Se consigue el máximo
aprovechamiento HW
• Cuanta mas carga,
mayor rendimiento
comparable
• Solo se registran
commits
Aislamiento basado en
snapshot
• No se usa tempdb
• Duplicación temporal
de filas
Concurrencia optimista
![Page 16: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/16.jpg)
Agenda
Motivación
Arquitectura
Uso de In-Memory OLTP
Coexistencia con otras tecnlogías
Aplicaciones prácticas
![Page 17: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/17.jpg)
![Page 18: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/18.jpg)
Aumentos de rendimiento
In-Memory
OLTP
CompilerIn-Memory
OLTP
component
Memory-optimized table
filegroupData filegroup
SQL Server.exe
In-Memory OLTP engine for
memory-optimized tables and
indexes
TDS handler and session management
Natively compiled
SPs and schema
Buffer pool for tables and
indexes
Proc/plan cache for ad-hoc T-
SQL and SPs
Client app
Transaction log
Interpreter for TSQL, query
plans, and expressions
Query
interop
Access methods
Parser,
Catalog,
Algebrizer,
Optimizer
10-30x mas eficiente
Reducción de consumo
de log
Checkpoints
secuenciales y en
background
Sin mejoras en pila de
llamadas, paso de
parámetros o devolución
de resultados
Key
Existing SQL
component
Generated .dll
![Page 19: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/19.jpg)
Aprovechamiento de In-Memory OLTP
Modo interpretado
• Hasta 3x de mejora de rendimiento
• Cuidado, podemos empeorar
• No requiere adaptar código
• Sintaxis completa
• Objetos in-memory y on-disk
• Recomendado para:
• Adhoc
• Migraciones rápidas a In-
Memory
Modo Nativo
• De 5x a 30x mejora de rendimiento
• En el caso peor 2x
• Adaptar stored procedures
• Sintaxis limitada
• Solo objetos in-memory
• Recomendado para:
• OLTP alto rendimiento
• Logica de negocio crítica
![Page 20: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/20.jpg)
![Page 21: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/21.jpg)
Agenda
Motivación
Arquitectura
Uso de In-Memory OLTP
Coexistencia con otras tecnologías
Aplicaciones prácticas
![Page 22: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/22.jpg)
Soportado
Parcialmente soportado
No soportado
• AlwaysON
• FCI
• Log Shipping
• Resource Governor
• Integration services
• Dacpac y bacpack
• Replicación transaccional (p2p no soportada)
• Instancia: TDE, MARS, CDC (se puede pero no recomendado)
• Objetos in-memory con Particionado, compresion, linked server, CT
Soporte de In-Memory en SQL Server
![Page 23: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/23.jpg)
Tablas
Procedimientos almacenados nativos
• CASE
• Subqueries
• OR
• Outer join
• Funciones de Sistema limitadas a matematicas ,date/time y texto
Limitaciones en In-Memory OLTP 2014
• Triggers DDL/DML
• Tipos de datos LOB, XML o CLR
• Foreign key o check constraints
• ALTER TABLE
• Añadir/quitar nuevos índices
![Page 24: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/24.jpg)
Agenda
Motivación
Arquitectura
Uso de In-Memory OLTP
Coexistencia con otras tecnologías
Aplicaciones prácticas
![Page 25: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/25.jpg)
26
Escenarios comunes de implementación In-Memory OLTP
Alto volumen de inserción de datos
Alto volumen de procesamiento durante inserción
Alto volumen de lecturas
Nuevos escenarios
• Escenario “shock absorver”
• Cargas masivas a DW
• Escenarios con tablas staging
• Similar al anterior
• *Lógica compleja en SP
• Caché transaccional
• Gestion de sesiones
• Zonas críticas que antes no se podían poner en base de datos relacional (generalmente por no poderse escalar verticalmente)
• Sistemas altamente estresados por peticiones de lecturas
• Las tablas de elevado % de lecturas pueden ser cuello de botella por LATCH_SH
![Page 26: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/26.jpg)
Conclusiones
27
• Nuevo motor totalmente integrado y sin coste añadido
• Mejoras de rendimiento de hasta 30x
• Permite exprimir eficientemente tu HW actual
• Tus conocimientos T-SQL son perfectamente válidos
![Page 28: In-Memory OLTP en SQL Server 2014](https://reader034.fdocuments.mx/reader034/viewer/2022052307/55864fd3d8b42ac4538b45a6/html5/thumbnails/28.jpg)