VI Sessão SQL Server BA - Plan guide

27
VI Sessão SQL Server BA 04/03/2017

Transcript of VI Sessão SQL Server BA - Plan guide

Page 1: VI Sessão SQL Server BA - Plan guide

VI Sessão SQL Server BA04/03/2017

Page 2: VI Sessão SQL Server BA - Plan guide

PASS.org Officially Launched!

Page 3: VI Sessão SQL Server BA - Plan guide

PASS Member Engagement Campaign

Stay tuned for updates on the Local Groups’ progress over the next few months!

Questions? Contact: [email protected]

From March 1st until May 31st, 2017, PASS will be supporting Local Group Leaders to engage with existing PASS members, as well as encourage new members to join Local Groups.

Our aim is to increase awareness of PASS as an organization, as well as the associated learning and networking opportunities available to members.

Local Groups who bring in the most new PASS members over the three month period, will be awarded VISA gift cards, in the following eight categories:

• USA/Canada – Small Group, Large Group

• EMEA – Small Group, Large Group

• LATAM – Small Group, Large Group

• APAC – Small Group, Large Group

Note: Small Groups = 250 members or less, Large Groups = 250+ Members

Page 4: VI Sessão SQL Server BA - Plan guide

Upcoming Virtual Group Sessions

VIRTUAL GROUP MEETING DATE TOPIC

PowerShell March 1 12:00-13:00 UTC + 11:00 Operational Validation of SQL Server at

scale with PowerShell and Jenkins

Global Italian March 1 14:30-15:30 UTC – 05:00 Rispondere agli Extended Event in tempo

reale

PowerShell March 1 14:30-15:30 UTC – 05:00 Converting Unreliable Deployments Into

Consistent Releases

Women in Technology March 2 12:00-13:00 UTC - 05:00 Moving Past Imposter Syndrome

DBA Fundamentals March 7 11:00-12:30 UTC - 06:00 Performance Troubleshooting Using Wait

Statistics

Database Administration March 8 12:00-13:00 UTC - 07:00 PowerShell for the DBA, Part 2 – Objects

and Tools.

Sponsored by: Hewlett Packard Enterprise

Page 5: VI Sessão SQL Server BA - Plan guide

Upcoming Virtual Group Sessions

VIRTUAL GROUP MEETING DATE TOPIC

Global Hebrew March 13 18:00-19:00 UTC + 02:00 Erin Stellato: Answering the Question,

“What Happened?” with Query Store.

Data Architecture March 14 13:00-14:00 UTC – 05:00 How to Get Started Tuning SQL Server

Performance – Tim Radney

Women in Technology March 15 16:00-17:00 UTC + 00:00 Kicking and Screaming: Replacing Profiler

with Extended Events with Erin Stellato

PowerShell March 15 12:00-13:00 UTC - 04:00 PowerShell for Implementation Engineers

Saturday Night SQL March 18 17:00-18:30 UTC - 04:00 Reports on the Go: SSRS 2016 Mobile

Reporting

DBA Fundamentals March 21 11:00-12:00 UTC - 05:00 Deadlocking for Mere Mortals

Page 6: VI Sessão SQL Server BA - Plan guide

Upcoming Virtual Group Sessions

VIRTUAL GROUP MEETING DATE TOPIC

Business Analytics March 21 09:00-10:00 UTC - 07:00 Excel to Power BI: 5 lessons you need to

unlearn to unlock Analytical Superpowers

by Avi Singh

Women in Technology March 21 13:00-14:00 UTC – 04:00 Seeking SQL Server Secrets

Women in Technology March 15 16:00-17:00 UTC + 00:00 Kicking and Screaming: Replacing Profiler

with Extended Events with Erin Stellato

Women in Technology March 29 12:00-13:00 UTC - 04:00 Identifying and Understanding Gender Bias

& Inequality

Page 7: VI Sessão SQL Server BA - Plan guide

PASS Virtual Groups

Page 8: VI Sessão SQL Server BA - Plan guide

Upcoming SQLSaturdays

US/Canada

LATAM

• Mar 4 Dallas: Power BI Edition

• Mar 11 Chicago

• Mar 11 Raleigh

• Mar 18 Richmond

• Mar 18 Birmingham

• Mar 18 Montreal

• Mar 25 Phoenix

• Mar 25 Colorado Springs

• Mar 11 Lisbon

• Mar 18 Iceland

• Mar 18 Belgrade

Visit sqlsaturday.com to register for an

event near you!

EMEA

APAC

Page 9: VI Sessão SQL Server BA - Plan guide

Connect with PASS

Sign up for a free membership today at:

pass.org

#sqlpass

Page 10: VI Sessão SQL Server BA - Plan guide

Conhecendo o Planguide

10

Page 11: VI Sessão SQL Server BA - Plan guide

Profile

Caio Amante

• Database Administrator (Dataside – SP);

• Moderador do grupo de Whatsapp SQL Maniacs;

• MCP;

• MCSA SQL Server 2012/2014;

• ITIL V3 foudation;

• ISO 27002;

• Trabalha 10 anos com tecnologia;

• CEO – Dataside Soluções em Banco de Dados;

• CEO – Aksource Soluções em TI;

[email protected]• https://www.facebook.com/caio.amante

• https://www.facebook.com/dataside/

• https://caiosamante.wordpress.com/

Page 12: VI Sessão SQL Server BA - Plan guide

Considerações

12

• Foco da apresentação;

• Nível 100/200;

• Falhas;

• Muito obrigado!

Page 13: VI Sessão SQL Server BA - Plan guide

Overview

13

• Inspiração;

• Objetivo do Plan guide;

• Hints;

• Execution Plan;

• Plan Cache;

• Surgimento no SQL Server 2005;

• Melhorias a partir do SQL Server 2008;

• Edições.

Page 14: VI Sessão SQL Server BA - Plan guide

Fluxo de operação

14

Page 15: VI Sessão SQL Server BA - Plan guide

Exemplo de Hint

15

SELECT * FROM Sales.SalesOrderHeader ORDER BY OrderDate DESCOPTION (MAXDOP 1)

SELECT * FROM Sales.SalesOrderHeader ORDER BY OrderDate DESC

Page 16: VI Sessão SQL Server BA - Plan guide

Estrutura do Plan Guide

16

@name: É o nome do plan guide

@stmt: A consulta a qual deve ser otimizada

@type: O tipo do plan guide, podendo ser um objeto, um SQL ou mesmo do tipo template.

@modulo_or_batch: O nome da procedure ou function, caso seja do tipo objeto, do contrário

este campo ficará nulo.

@params: parâmetros definidos na sentença, usados para templates.

@hints: São hints de query e tabela que queremos forçar o sql.

Page 17: VI Sessão SQL Server BA - Plan guide

Tipos de Plan guide

17

• Object;

• SQL;

• Template.

Page 18: VI Sessão SQL Server BA - Plan guide

SQL Plan Guide

18

• Quando utilizar;

• Ad-hoc;

• Não exige parametro @module_or_batch;

• A batch assume o valor do Statement.

Page 19: VI Sessão SQL Server BA - Plan guide

Demo 1

19

Page 20: VI Sessão SQL Server BA - Plan guide

Object Plan Guide

20

• Quando utilizar;

• Triggers, functions, Procedures;

• Exige parametro @module_or_batch;

• Multi planguides para um objeto.

Page 21: VI Sessão SQL Server BA - Plan guide

Demo 2

21

Page 22: VI Sessão SQL Server BA - Plan guide

Template Plan Guide

22

• Específico para forçar parametrizações;

• Force e Simple;

• sp_get_query_template;

• @params.

Page 23: VI Sessão SQL Server BA - Plan guide

Demo 3 e 4

23

Page 24: VI Sessão SQL Server BA - Plan guide

Gerenciando o Plan Guide

24

Temos seis valores obrigatórios possíveis para executarmos este procedimento, são eles:

DISABLE, DISABLE ALL, ENABLE, ENABLE ALL, DROP e DROP ALL. Podemos colocar o nome do

plan guide, no entanto este é opcional.

• Exemplo: Sp_control_plan_guide DISABLE,’Template_Plan’

Page 25: VI Sessão SQL Server BA - Plan guide

Cuidados

25

• Migrações;

• Limitações;

• Hints, aprecie com moderação;

• Estude!

Page 26: VI Sessão SQL Server BA - Plan guide

Dúvidas?

26

Page 27: VI Sessão SQL Server BA - Plan guide

Motivação

27

“Tudo que a mente

humano pode conceber,

ela pode conquistar.”