A Shot of SQLEspresso

SQL Blogs by Monica Morehouse (Rathbun)

  • Home
  • Session Downloads
  • Event Calendar
  • PASS
    • Hampton Roads SQL User Group
    • SQL Saturday
    • PASS WIT VC
  • DCAC
  • Contact Me
    • Disclaimer
  • Home
  • Session Downloads
  • Event Calendar
  • PASS
    • Hampton Roads SQL User Group
    • SQL Saturday
    • PASS WIT VC
  • DCAC
  • Contact Me
    • Disclaimer

No Widgets found in the Sidebar Alt!

  • Back to Basics,  Performance Tuning,  Posts with Scripts

    Quick Tip: Remove CONVERT\CAST from your WHERE\JOIN clauses

    March 28, 2022 /

    Quick Tip Remove CONVERT/CAST from your WHERE clauses and JOINS when comparing to variables of different data types. Set their data types to match your table definitions before using them as a filter. Optimizing your queries this way will greatly reduce the amount of CPU time, reads, and I/O generated in your queries and allow your code to take better advantage of indexes. Example We are going to create a very simple stored procedure called ConvertExample. In this procedure we will see two things. One, the first procedure we create will declare two variables as VARCHAR( MAX) data types, then in the WHERE clause it will convert a table column…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    Approximate COUNT DISTINCT

    January 3, 2019

    My Thoughts on PASS Virtual Summit – An Editorial

    June 11, 2020

    Are My SQL Server Indexes Being Used?

    August 28, 2019
  • Performance Tuning

    Add DBCC INPUTBUFFER to Your Performance Tuning Toolbox

    July 7, 2021 /

    A command I like to use when performance tuning is DBCC INPUTBUFFER. If you have ever run sp_whoisactive or sp_who2 to find out what sessions are executing when CPU is high for instance this can be a real quick life saver. At times, for me, those two options do not return enough information for what I’m looking for which is the associated stored procedure or object. Using this little helper along with the session id can easily get you that information. Let’s take a look. First, I will create a simple procedure to generate a workload. CREATE OR ALTER PROCEDURE KeepRunning AS DECLARE @i INT=1 WHILE (@i <1000) BEGIN select…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    Quick Model Database Tidbit

    October 30, 2017

    Replication Max Text Length

    June 20, 2018

    Change Azure SQL Database Service Level Objectives in SSMS

    August 28, 2020
  • Azure,  Performance Tuning

    Adaptive Joins in SQL Server

    September 2, 2020 /

    SQL Server 2017 (compatibility 140) brought us many Intelligent Query Processing (IQP), formally known as Adaptive Query Processing, features that improve performance on workloads straight out of the box with no code changes to implement. One of those features introduced was Adaptive Joins. In this feature the join operator is dynamically determined at runtime by the optimizer, which defines a threshold number of rows and then chooses between a Nested Loop or Hash Match join operator. This operator switch can produce a better join and improve performance of your queries without you having to lift a finger. Not all queries will qualify for this new feature. The feature only applies…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    5 Ways to Examine Cardinality Metrics

    May 2, 2018

    Live, Learn, and Grow

    April 25, 2018

    The Mystery of the Locked-Up Database -Scooby Dooing Episode 6

    September 24, 2025
  • Performance Tuning

    Sorting in Stored Procedures – Food for Thought

    January 29, 2020 /

    We know that sorting can be one of the most expensive things in an execution plan as shown below. However,  we continue to do ORDER BYs repeatedly. Yes, I 100% agree that there is a need to sort a results set and that this should be done in the procedure for good reason, but my concern is having  multiple sorts, erroneous sorts, and the sorts that can be done elsewhere. These are the ones that waste resources and can stifle performance. Many of us writing procedures tend to write in code blocks. We write the SELECT, JOINS, FROMs and WHERES then immediately follow it up with and ORDER BY as…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    What does this little check box do? Query Governor SQL Database Setting

    September 13, 2017

    DMV’s for the Beginner

    May 15, 2019

    Respectfully Responding

    June 14, 2018
  • Back to Basics,  Performance Tuning

    What’s a Key Lookup?

    April 3, 2019 /

    One of the easiest things to fix when performance tuning queries are Key Lookups or RID Lookups. The key lookup operator occurs when the query optimizer performs an index seek against a specific table and that index does not have all of the columns needed to fulfill the result set. SQL Server is forced to go back to the clustered index using the Primary Key and retrieve the remaining columns it needs to satisfy the request. A RID lookup is the same operation but is performed on a table with no clustered index, otherwise known as a heap.  It uses a row id instead of a primary key to do…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    Query Predicates in SQL Server

    May 24, 2018

    SQL Index Creation Using DROP EXISTING= ON

    February 17, 2021

    Quick Model Database Tidbit

    October 30, 2017
  • Back to Basics,  Posts with Scripts,  Quick and Dirty

    Back to Basics: Why not parameterize?

    December 23, 2015 /

    I think sometimes those of us that have been doing database administration/development for a while take it for granted that everyone knows the basics. One such basic is parameterizing stored procedures. This allows us to potentially consolidate multiple stored procedures into a single procedure.  It’s as simple thing to do that many don’t. I try to parameterize as many stored procedures as possible. This not only minimizes the amount of procedures I need to maintain, it in my opinion is a much cleaner way to code. It disturbs me when I see multiple stored procedures that pull the exact same data, but may have slight differences between them. Whether it…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    This Idera ACE Has Been Busy

    August 23, 2016

    So let’s talk naming conventions

    September 15, 2015

    Replication Max Text Length

    June 20, 2018
  • Quick and Dirty

    QUICK & DIRTY: Table name change for all stored procedures

    December 10, 2015 /

    Recently, I was tasked to find all stored procedures in a database that use a particular table and change them to utilize another table. I needed to get this done quickly so I decided to think simple. Since it was a quick and dirty answer I figured I would share, it’s not rocket science, but useful none the less. The quick answer that I came up with is to script out all of the stored procedures into a single query window.  This can be done easily through the GUI.  Once that is complete, I can easily do a “Find & Replace” on the table name and we’re done! Let me…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    In Memory Table Indexes

    January 22, 2020

    Attending Summit as a New Leader

    November 6, 2015

    Introduction to the performance features on SQL Server on Linux

    December 4, 2019
  • Uncategorized

    So let’s talk naming conventions

    September 15, 2015 /

    How many of you have come across a database that had stored procedures, views or functions and you had no clue, by name, what they were for? Having standard naming conventions helps to prevent that. Everyone has their own preferences and opinions on what they should be, so I thought I’d share mine. My opinion In a nutshell, the name of any object should be informative; specifically what the object is used for and where it is used. This is accomplished by utilizing prefixes in conjunction with specific naming conventions.  I apply these standards to all of my stored procedures, views, and functions, whenever possible. Of course there are always…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    5 Ways to Examine Cardinality Metrics

    May 2, 2018

    Caution When Dropping Unused Indexes on an Azure SQL Database

    August 12, 2020

    Filtered Index Basics

    May 22, 2019

About Me

Monica Morehouse (Rathbun)

Microsoft MVP, Performancing Tuning Expert, Leader Hampton Roads SQL Server User Group, Read More…

Consulting

Sessions List

Favorite Tidbits

  • Reminder to Developers

Topic Categories

  • Azure
  • Back to Basics
  • Configurations
  • Data Masking
  • DevOps
  • Encryption
  • Idera Ace
  • Important Links
  • Indexes
  • Lone DBA
  • Misc
  • MVP
  • New SQL Version
  • Performance Tuning
  • Posts with Scripts
  • Problems & Solutions
  • Quick and Dirty
  • Security
  • Speaking
  • SQL Family
  • SQLSaturday
  • SSRS
  • Summit
  • Training
  • TSQL Tuesday
  • Uncategorized

Top Posts & Pages

  • Memory Optimized Tables in SQL Server
    Memory Optimized Tables in SQL Server
  • Resizing Tempdb (When TEMPDB Wont Shrink)
    Resizing Tempdb (When TEMPDB Wont Shrink)
  • DMV’s for the Beginner
    DMV’s for the Beginner
  • Hide and Group Columns in SSRS Using a Parameter
    Hide and Group Columns in SSRS Using a Parameter
  • Change Azure SQL Database Service Level Objectives in SSMS
    Change Azure SQL Database Service Level Objectives in SSMS
  • Careful with your SQL Server Max Memory settings
    Careful with your SQL Server Max Memory settings
  • Add DBCC INPUTBUFFER to Your Performance Tuning Toolbox
    Add DBCC INPUTBUFFER to Your Performance Tuning Toolbox
  • Understanding Columnstore Indexes in SQL Server Part 1
    Understanding Columnstore Indexes in SQL Server Part 1
  • Tempdb Performance Improvements in SQL Server 2022 are Dramatic
    Tempdb Performance Improvements in SQL Server 2022 are Dramatic
  • The Gang vs. Jason: Unmasking JSON’s Secrets in SQL Server 2025- Scooby Dooing Episode 7
    The Gang vs. Jason: Unmasking JSON’s Secrets in SQL Server 2025- Scooby Dooing Episode 7
Graceful Pro Theme by Optima Themes - 2026 ©
 

Loading Comments...