SQL Server rápido y furioso
-
Upload
spanishpassvc -
Category
Technology
-
view
362 -
download
4
Transcript of SQL Server rápido y furioso
![Page 1: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/1.jpg)
SQL Server Rápido y Furioso02 de Setiembre 2015 (12 pm
GMT -5)Alejandro Cordero
Resumen:En esta sesión analizaremos experiencias de la vida real como consultor en trabajos de mejora de rendimiento. Veremos mejores prácticas para la configuración de SQL Server, tips para un mejor T-SQL.
Está por comenzar:
Moderador: Carlos Ulate
Próximos Eventos
16 de SetiembreJavier Villegas
SQL como un servicio en la nube
09 de SetiembreWarner Chaves
Query Store en SQL 2016
23 de SetiembreRicardo Estrada
SQL Monitoring
![Page 2: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/2.jpg)
Manténgase conectado a nosotros!
Visítenos en http://globalspanish.sqlpass.org
/SpanishPASSVC
lnkd.in/dtYBzev
/user/SpanishPASSVC
/SpanishPASSVC
![Page 3: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/3.jpg)
3
![Page 4: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/4.jpg)
4
Oportunidades de Voluntariado
PASS no pudiera existir sin personas apasionadas y dedicadas de todas partes del
mundo que dan de su tiempo como voluntarios.
Se un voluntario ahora!!
Para identificar oportunidades locales visita volunteer.sqlpass.org
Recuerda actualizar tu perfil en las secciones de “MyVolunteering” y MyPASS para mas
detalles.
![Page 5: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/5.jpg)
Sigan Participando!• Obtén tu membresía gratuita en sqlpass.org
• Linked In: http://www.sqlpass.org/linkedin• Facebook: http://www.sqlpass.org/facebook• Twitter: @SQLPASS• PASS: http://www.sqlpass.org
![Page 6: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/6.jpg)
SQL Server Rápido y Furioso
02 de Setiembre de 2015
Alejandro CorderoMCTS , CSM – Consultor de Bases de Datos en Pythian
Moderador: Carlos Ulate
![Page 7: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/7.jpg)
Agenda
Configuración General SQL ServerTablas Variables vrs Tablas TemporalesBúsqueda de textos – SargabilidadQuery HintsIndices Sugeridos y sin UsarProgramación “Set Based”SQL2014 – In Memory
7
![Page 8: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/8.jpg)
Configuración General
CPU cores vrs Archivos de Tempdb.
8
PAGELATCH_UP, PAGELATCH_EX, or PAGELATCH_SH
![Page 9: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/9.jpg)
Configuración General
Crecimiento de los archivos de base de datos
![Page 10: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/10.jpg)
Configuración General
Memoria Máxima
![Page 11: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/11.jpg)
Configuración General
Organización en disco
Datafile
Transaction log
TempDB
Backups
![Page 12: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/12.jpg)
Demo
Configuremos una instancia de SQL Server
![Page 13: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/13.jpg)
Tablas Variables vrs Tablas Temporales
El estimado de líneas de información(tuplas) es diferente, para las variables se estima 1 sola línea, para las temporales la estimación es más cercana al contenido real de la tabla
Declare @temp table(campo1 int, campo2 char(1))Create table #temp(campo1 int, campo2 char(1))
![Page 14: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/14.jpg)
Demo
Plan de Ejecución de tablas variables vrs tablas temporales
![Page 15: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/15.jpg)
Búsquedas de Texto
Diferencias en el uso del operador like
Find date values in a certain year:Non-sargable: SELECT ... WHERE EXTRACT(YEAR FROM date) = 2012Sargable: SELECT ... WHERE date >= '2012-01-01' AND date < '2013-01-01'Handling NULLs:Non-sargable: SELECT ... WHERE COALESCE(FullName, 'John Smith') = 'John Smith'Sargable: SELECT ... WHERE (FullName = 'John Smith') OR (FullName IS NULL)String prefix search:Non-sargable: SELECT ... WHERE SUBSTRING(DealerName FROM 1 FOR 6) = 'Toyota'Sargable: SELECT ... WHERE DealerName LIKE 'Toyota%'String postfix search:Non-sargable: SELECT ... WHERE Email LIKE '%wikipedia.org'Sargable: SELECT ... WHERE REVERSE(Email) LIKE REVERSE('%wikipedia.org')
![Page 16: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/16.jpg)
Demo
Planes de ejecución en un like
![Page 17: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/17.jpg)
Query HINTS
MAXDOPNOLOCKFORCESEEKRECOMPILEOPTIMIZE FOR UNKNOWNMAX_GRANT_PERCENT – SQL Server 2016!
![Page 18: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/18.jpg)
Parameter Sniffing
@begindate=‘2005-01-02’
Plan 1
@begindate=‘2006-01-02’
Plan 2
@begindate=‘2007-01-02’
Plan 3
EXEC dbo.DisplayBillingInfo @BeginDate = '2005-01-01', @EndDate = '2005-01-03';
![Page 19: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/19.jpg)
Demo
Probando Query Hints
![Page 20: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/20.jpg)
Índices sugeridos y sin usar
Revisando estadísticas de uso con sys.dm_db_index_usage_statsRevisando sugerencias del motor de base de datos con sys.dm_db_missing_index_group_stats, sys.dm_db_missing_index_detailsTomar en cuenta último inicio del servicio de SQL Server
![Page 21: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/21.jpg)
Demo
Scripts de revisión
![Page 22: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/22.jpg)
Programación “Set Based”
Pensar en la teoría de conjuntosTratar siempre de aplicar una transacción a un grupo de datos en lugar de uno a la vezEvitar iteraciones, ciclos, condicionales, etc.Usar vistas, agregaciones, funciones, etc
![Page 23: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/23.jpg)
Demo
Código hecho en set based programming vrs código usual de aplicación (ejemplos TSQL)
![Page 24: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/24.jpg)
In -memory
Utilizar tablas in memory
![Page 25: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/25.jpg)
Demo
Comparativa de rendimiento, tabla normal vrs In- Memory
![Page 26: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/26.jpg)
Preguntas?
![Page 28: SQL Server rápido y furioso](https://reader036.fdocuments.ec/reader036/viewer/2022081722/58ec961a1a28ab16648b4689/html5/thumbnails/28.jpg)
SQL como un servicio en la nube09 de Setiembre (12 pm
GMT -5)Warner ChavesResúmen:
La guerra de los proveedores de servicios de computo en la nube continua y esto incluye servicios de bases de datos. Estos servicios proveen una plataforma donde las tareas de administracion son menores a cambio de menos control sobre la plataforma. En esta sesion haremos una comparacion entre las dos plataformas mas populares para SQL Server: Amazon RDS y Azure SQL DB y veremos cuales son las fortalezas y debilidades de cada una.
Próximo Evento