VI Sessão SQL Server BA - Plan guide

Post on 22-Jan-2018

271 views 0 download

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

VI Sessão SQL Server BA04/03/2017

PASS.org Officially Launched!

PASS Member Engagement Campaign

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

Questions? Contact: CommunityTeam@pass.org

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

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

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

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

PASS Virtual Groups

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

Connect with PASS

Sign up for a free membership today at:

pass.org

#sqlpass

Conhecendo o Planguide

10

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;

• caio.amante@dataside.com.br• https://www.facebook.com/caio.amante

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

• https://caiosamante.wordpress.com/

Considerações

12

• Foco da apresentação;

• Nível 100/200;

• Falhas;

• Muito obrigado!

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.

Fluxo de operação

14

Exemplo de Hint

15

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

SELECT * FROM Sales.SalesOrderHeader ORDER BY OrderDate DESC

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.

Tipos de Plan guide

17

• Object;

• SQL;

• Template.

SQL Plan Guide

18

• Quando utilizar;

• Ad-hoc;

• Não exige parametro @module_or_batch;

• A batch assume o valor do Statement.

Demo 1

19

Object Plan Guide

20

• Quando utilizar;

• Triggers, functions, Procedures;

• Exige parametro @module_or_batch;

• Multi planguides para um objeto.

Demo 2

21

Template Plan Guide

22

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

• Force e Simple;

• sp_get_query_template;

• @params.

Demo 3 e 4

23

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’

Cuidados

25

• Migrações;

• Limitações;

• Hints, aprecie com moderação;

• Estude!

Dúvidas?

26

Motivação

27

“Tudo que a mente

humano pode conceber,

ela pode conquistar.”