Trigram Wildcard String Search in SQL Server
Searching string data for an arbitrary substring match can be an expensive operation in SQL Server. Queries of the form Column LIKE '%match%' cannot use the seeking abilities of a b-tree index, so the...
View ArticleImpact of Fragmentation on Execution Plans
Index fragmentation removal and prevention has long been a part of normal database maintenance operations, not only in SQL Server, but across many platforms. Index fragmentation affects performance for...
View ArticleQ & A from our Parameter Sniffing webinar series
The past two Wednesdays, we have hosted a two-part webinar series treating parameter sensitivity issues: Stored Procedures, Parameters, Problems… Kimberly L. Tripp and Aaron Bertrand January 24th...
View ArticleAutomatic Plan Correction in SQL Server
How much time do you spend troubleshooting performance issues as a Database Administrator or Developer? Have you ever tracked it? As the average total percentage of your day, it may not look like a lot...
View ArticleWhen DISTINCT GROUP BY
I wrote a post recently about DISTINCT and GROUP BY. It was a comparison that showed that GROUP BY is generally a better option than DISTINCT. It's on a different site, but be sure to come back to...
View ArticleDealing with date and time instead of datetime
Data professionals don’t always get to use databases that have an optimal design. Sometimes the things that make you cry are things that we’ve done to ourselves, because they seemed like good ideas at...
View ArticleJoin Elimination: When SQL Server Removes Unnecessary Tables
Guest Author : Bert Wagner (@bertwagner) Join elimination is one of the many techniques that the SQL Server query optimizer uses to create efficient query plans. Specifically, join elimination occurs...
View ArticleSpecial Islands
Gaps and Islands tasks are classic querying challenges where you need to identify ranges of missing values and ranges of existing values in a sequence. The sequence is often based on some date, or date...
View ArticleReader solutions to Special Islands challenge
Last month I covered a Special Islands challenge. The task was to identify periods of activity for each service ID, tolerating a gap of up to an input number of seconds (@allowedgap). The caveat was...
View ArticleClosest Match, Part 1
Karen Ly, a Jr. Fixed Income Analyst at RBC, gave me a T-SQL challenge that involves finding the closest match, as opposed to finding an exact match. In this article I cover a generalized, simplistic,...
View ArticleImprove Performance of UDFs with NULL ON NULL INPUT
At PASS Summit a few weeks ago, Microsoft released CTP2.1 of SQL Server 2019, and one of the big feature enhancements that is included in the CTP is Scalar UDF Inlining. Prior to this release I wanted...
View ArticleClosest Match, Part 2
Last month, I covered a puzzle involving matching each row from one table with the closest match from another table. I got this puzzle from Karen Ly, a Jr. Fixed Income Analyst at RBC. I covered two...
View ArticleClosest Match, Part 3
In Closest Match, Part 1, I covered a T-SQL challenge that was provided to me by Karen Ly, a Jr. Fixed Income Analyst at RBC. The challenge involved two tables — T1 and T2, each with a key column...
View ArticleCharlotte SQL Server User Group : Fix Slow Queries. Fast.
On February 20th, I spoke at the Charlotte SQL Server User Group, giving a new presentation: "Fix Slow Queries. Fast." This session was largely a walk-through of the various query tuning techniques...
View ArticleT-SQL bugs, pitfalls, and best practices – determinism
Like any programming language, T-SQL has its share of common bugs and pitfalls, some of which cause incorrect results and others cause performance problems. In many of those cases, there are best...
View ArticleFiltered Indexes and INCLUDEd Columns
Filtered indexes are amazingly powerful, but I still see some confusion out there about them – particularly about the columns that are used in the filters, and what happens when you want to tighten the...
View ArticleRow Pattern Recognition in SQL
The ISO/IEC 9075:2016 standard, or SQL:2016 in short, introduces support for a profound concept called Row Pattern Recognition (RPR) in SQL. I posted a suggestion to improve SQL Server by adding...
View ArticleT-SQL bugs, pitfalls, and best practices – subqueries
This article is the second in a series about T-SQL bugs, pitfalls and best practices. This time I focus on classic bugs involving subqueries. Particularly, I cover substitution errors and three-valued...
View ArticleT-SQL bugs, pitfalls, and best practices – joins
This article is the third installment in a series about T-SQL bugs, pitfalls and best practices. Previously I covered determinism and subqueries. This time I focus on joins. Some of the bugs and best...
View ArticleUnintended Side Effects – Sleeping Sessions Holding Locks
A recent consulting engagement was focused on blocking issues inside of SQL Server that were causing delays in processing user requests from the application. As we started to dig into the issues being...
View Article