Stop Doing That! Common T-SQL Anti-Patterns ~ Wolf ~ This template can be used as a starter file for presenting training materials in a group setting. Sections Right-click on a slide to add sections. Sections can help to organize your slides or facilitate collaboration between multiple authors. Notes Use the Notes section for delivery notes or to provide additional details for the audience. View these notes in Presentation View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production) Coordinated colors Pay particular attention to the graphs, charts, and text boxes. Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale. Graphics, tables, and graphs Keep it simple: If possible, use consistent, non-distracting styles and colors. Label all graphs and tables.
Resources to use: #sqlsatNYC #sqlhelp #sqlserver Add slides to each topic section as necessary, including slides with tables, graphs, and images. See next section for sample table, graph, image, and video layouts. #sqlsatNYC #sqlhelp #sqlserver
About Wolf DBA for 16 years, SQL Server/Oracle combination At RDX for 6 years. “Manager – SQL Server Performance Tuning” Works with a variety of clients and challenges Give a brief overview of the presentation. Describe the major focus of the presentation and why it is important. Introduce each of the major topics. To provide a road map for the audience, you can repeat this Overview slide throughout the presentation, highlighting the particular topic you will discuss next.
There are 2 types of people in this world… http://newmediadl.cas.msu.edu/sites/default/files/uploads/users/1003/yankees-business-model1.jpg https://upload.wikimedia.org/wikipedia/en/thumb/a/aa/RedSoxSecondary_Circle.svg/1024px-RedSoxSecondary_Circle.svg.png
There are 2 types of people in this world… http://newmediadl.cas.msu.edu/sites/default/files/uploads/users/1003/yankees-business-model1.jpg https://upload.wikimedia.org/wikipedia/en/thumb/a/aa/RedSoxSecondary_Circle.svg/1024px-RedSoxSecondary_Circle.svg.png
Star Trek: Next Generation - http://i.stack.imgur.com/NTsOF.jpg
What we will focus on 1 2 3 Scalar-Value Function as part of Select State of the Union 2 Common Table Expressions 3 SARGability 4 This is another option for an Overview slide.
Scalar-Valued Function in the Select Use a section header for each of the topics, so there is a clear transition to the audience. Scalar-Valued Function in the Select
What is a Scalar-Valued Function? Scalar functions return a single data value of the type defined in the RETURNS clause. Supports nearly all data types with the exception of text, ntext, image, and timestamp Let’s see how they work Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
What did we see Scalar-Valued Function is great to reuse code When used as part of the select, the function will read, Row by Agonizing Row(RBAR) Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
Use a section header for each of the topics, so there is a clear transition to the audience. State of the Union
What is a Union? Union combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. Union is a great way to give a unique results set from different queries. A Union specifies that multiple result sets are to be combined and returned as a single result set. Let’s see how they work Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
What did we see? The union operator has its uses, but we can see that those uses come at a cost of reads and tempdb usage. At times, we may not have an alternative, but we need to be aware of the costs and use this functionality accordingly. Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
Common Table Expressions(CTE) Use a section header for each of the topics, so there is a clear transition to the audience. Common Table Expressions(CTE)
What are CTE? A common table expression (CTE) can be thought of as a defined derived table that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. Unlike a derived table, a CTE can be self- referencing and can be referenced multiple times in the same query. Add slides to each topic section as necessary, including slides with tables, graphs, and images. See next section for sample table, graph, image, and video layouts.
What did we see? CTE are a defined derived table With small recordsets and simple queries, they are acceptable They have no statistics or indexes available. They will not scale well Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
Use a section header for each of the topics, so there is a clear transition to the audience. SARGable
What is a SARGability? In relational databases, a condition (or predicate) in a query is said to be sargable if the DBMS engine can take advantage of an index to speed up the execution of the query. The term is derived from a contraction of Search ARGument ABLE. As DBAs, we do our best to write the queries to take advantage of the indexes as best we can. Searching! Seek and Destroy! Add slides to each topic section as necessary, including slides with tables, graphs, and images. See next section for sample table, graph, image, and video layouts.
What did we see? When we don’t take advantage of SARGability, we make the database work much harder than it needs to. Use “LIKE”, built-in functions and scalar- valued functions sparingly. Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share. Under File Types, click Create a Video.)
Forest Gump: http://funnyand
http://camurren.com/wp-content/uploads/2015/09/20150302162232-turtle-skateboard.jpeg
Metallica – Through The Never Movie https://youtu.be/kV-2Q8QtCY4
Microsoft Engineering Excellence Questions? Microsoft Confidential