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

    The Gang vs. Jason: Unmasking JSON’s Secrets in SQL Server 2025- Scooby Dooing Episode 7

    October 1, 2025

    What is Automatic Tuning in Azure SQL Database

    August 28, 2018

    Please Don’t Do This! Default Index Fill Factor

    September 6, 2017
  • 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

    Static Data Masking (SSMS 18.0 Preview)

    December 19, 2018

    Please Don’t Do This! Default Index Fill Factor

    September 6, 2017

    SQL Server Data Collection and Management Data Warehouse

    October 3, 2018
  • 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

    Master of None

    October 8, 2015

    Query Predicates in SQL Server

    May 24, 2018

    The FAST number_rows Query Hint

    October 16, 2019
  • 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

    Ooops! Was that me? (Blog Challenge)

    January 10, 2017

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

    March 28, 2022

    Replication Max Text Length

    June 20, 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

    Keep It Simple Stupid

    July 24, 2019

    Free Training 24HOP

    April 18, 2018

    Please Don’t Do This! Default Index Fill Factor

    September 6, 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

    Change Azure SQL Database Service Level Objectives in SSMS

    August 28, 2020

    Understanding Columnstore Indexes in SQL Server Part 1

    June 26, 2019

    Introduction to the performance features on SQL Server on Linux

    December 4, 2019
  • 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

    Can You Hear It Now?

    January 31, 2018

    Caution When Dropping Unused Indexes on an Azure SQL Database

    August 12, 2020

    What SQL Server Performance & Management Tools Do I Use?

    September 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

    Quick Model Database Tidbit

    October 30, 2017

    System-Versioned Temporal Tables

    August 30, 2017

    SQL Server Data Collection and Management Data Warehouse

    October 3, 2018

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

  • Resizing Tempdb (When TEMPDB Wont Shrink)
    Resizing Tempdb (When TEMPDB Wont Shrink)
  • What’s a Key Lookup?
    What’s a Key Lookup?
  • DMV’s for the Beginner
    DMV’s for the Beginner
  • It's All in the Name, Index Naming Conventions
    It's All in the Name, Index Naming Conventions
  • Scooby Dooing Episode 10: The Case of the Copy-and-Paste Consultant
    Scooby Dooing Episode 10: The Case of the Copy-and-Paste Consultant
  • Please Don’t Do This! Default Index Fill Factor
    Please Don’t Do This! Default Index Fill Factor
  • Ruh-Roh! SQL Server 2025 Finally Brings Us a Free Standard Developer Edition -  Scooby Dooing Episode 2
    Ruh-Roh! SQL Server 2025 Finally Brings Us a Free Standard Developer Edition - Scooby Dooing Episode 2
  • Initial SQL Server Configurations
    Initial SQL Server Configurations
  • The Mystery of the Locked-Up Database -Scooby Dooing Episode 6
    The Mystery of the Locked-Up Database -Scooby Dooing Episode 6
  • SSRS Report Won’t Render in VS Preview
    SSRS Report Won’t Render in VS Preview
Graceful Pro Theme by Optima Themes - 2026 ©
 

Loading Comments...