Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

People Make Odd Choices

One of my favorite things about going to in-person events is just the time when we're sitting around chatting, out in the hallway, over at the vendor booths, maybe in the speaker room. Any of them. Inevitably, you start to get what I would call "sea stories" (Navy & Coasties, "war stories" for the pickles, "hangar stories" for the zoomies, and evidently, "orbital anecdotes" for the floatybois). They usually start with "No kidding, there I was..." (although, the language is absolutely saltier). We have the same in computing and IT. I'm going to repeat one that I heard at Swiss pgDay because it was absolutely too marvelous not to. No names. Details are left out or changed. I told the person I was going to steal their story too, so no worries there.

No kidding, there they were, faced with a major performance bottleneck. Word was that the data movement was taking hours and hours. Our hero was brought in as a consultant to figure out what was up. Again, no details, but this is PostgreSQL we're talking about. There's a strong possibility that someone thought turning off the auto vacuum was a good idea (evidently, this is insanely common). Our hero turned it back on. That one change turned the process from hours into seconds. Ta-da! Winner.

Until, they get a call a couple of weeks later. Seems performance has degraded again. Oh, it's not as bad as it was. Instead of hours to do the data load, now it's only about 20 minutes or so. Our hero goes back. Nope, not the auto vacuum. They keep poking around until they find a new line of code has been added to the data load process: pg_sleep(1200);. For those who don't know, that just pauses everything for about 20 minutes. Before going to the boss with a solution, our hero talked to the team in charge. They had an immediate answer. See, having the data load process take only seconds really stepped on their ability to take a break for smoking. But hey, just putting a 20 minute pause in fixed that problem.

True story, or so I was told. As I said, sea stories. You can't always trust 'em. However, I couldn't stop laughing. I mean, come on. I know AI is coming for jobs... maybe... but oh man, it's never going to do stuff like that. Humans are, without a doubt, special critters.

Got any good ones to share? Just remember the rules: there are no rules other than it has to start with something along the lines of "Not fooling. There I was, in the mess, with the grunts...". Although, let's avoid the salty language. Ha!

Grant Fritchey

Join the debate, and respond to today's editorial on the forums

 
  Featured Contents
SQLServerCentral Article

SQL Server 2022 Clusterless Distributed Availability Group

Pablo Echeverria from SQLServerCentral

This article shows the final step of an availability group creation, specifically for a distributed clusterless one.

Blog Post

From the SQL Server Central Blogs - Monday Monitor Tips: Searching Permission Changes

Steve Jones - SSC Editor from The Voice of the DBA

During a demo of Redgate Monitor Enterprise to a customer, they asked about how to search for permission changes. This post examines how you can do that in Redgate...

Blog Post

From the SQL Server Central Blogs - Generative AI vs Predictive AI | Real-World Examples & Tools You Should Know

Rohit Garg from MSSQLFUN

What is Artificial Intelligence? Understanding Predictive vs. Generative AI Artificial Intelligence (AI) is transforming how we live, work, and interact with technology. From personalized recommendations to AI-generated art, the...

Microsoft Power BI Quickstart Guide cover

Microsoft Power BI Quick Start Guide: The ultimate beginner's guide to data modeling, visualization, digital storytelling, and more, 3rd Edition

Site Owners from SQLServerCentral

Bring your data to life with this accessible yet fast-paced introduction to Power BI, now in color.

 

  Question of the Day

Today's question (by Grant Fritchey):

 

SQL Server Columnstore Index Fragmentation

The columnstore index is absolutely different than the traditional rowstore b-tree index. Because of this, it doesn't suffer from the same kind of fragmentation across pages as the b-tree index. Yet, it does suffer from a type of fragmentation brought about by an excess of deleted rows in a rowgroup and a lack of compression of storage because more things are in the delta store. While b-tree indexes use dm_db_index_physical_stats to show fragmentation, which system tables or DMVs can be used in SQL Server (prior to SQL Server 2025) to determine columnstore fragmentation?

Think you know the answer? Click here, and find out if you are right.

 

 

  Yesterday's Question of the Day (by dbakevlar)

Query Plan Regressions --

For the Question of the day, I am going to go deep, but try to be more clear, as I feel like I didn't give enough info last time, leading folks to guess the wrong answer... :)

For today's question:  You’re troubleshooting a performance issue on a critical stored procedure. You notice that a previously efficient query now performs a full table scan instead of an index seek. Upon investigating, you find that an NVARCHAR parameter is being compared to a VARCHAR column in the WHERE clause. What is the most likely cause of the query plan regression?

Answer: Implicit conversion preventing index seek

Explanation:

Explanation:

When an NVARCHAR parameter is compared to a VARCHAR column, SQL Server must perform an implicit conversion of the column to NVARCHAR to evaluate the predicate.  This prevents the optimizer from using the index on the VARCHAR column efficiently, often resulting in a table scan.  This is a classic performance pitfall, especially in parameterized stored procedures or queries where mismatched data types are used.

While parameter sniffing (A) and statistics issues (C) can affect performance, in this case, the root cause is (B), which is known as the implicit conversion.

You may have guessed (D) but it's misleading because SQL Server doesn’t “ignore” the index due to precedence, it simply misapplies it due to the need to cast.

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2019 - Development
do i lose "what this object depends on" etc when moving sprocs to etl server - Hi i was surprised to see the approach my coworkers used to sunset talend , a combo etl and job scheduling tool.  They were in a hurry. Basically, the talend transforms /jobs they needed to do something with ran a proc on the "ERP Servers" and loaded the extracted data into various databases on our […]
Editorials
People Make Odd Choices - Comments posted to this topic are about the item People Make Odd Choices
Navigating Multi Platform Realities in My Database Life - Comments posted to this topic are about the item Navigating Multi Platform Realities in My Database Life
Formatting Dates and Times: The SQL Dialect Divide - Comments posted to this topic are about the item Formatting Dates and Times: The SQL Dialect Divide
Article Discussions by Author
How a Legacy Logic Choked SQL Server in a 30-Year-Old Factory - Comments posted to this topic are about the item How a Legacy Logic Choked SQL Server in a 30-Year-Old Factory, which is is not currently available on the site.
SQL Server 2022 Clusterless Distributed Availability Group - Comments posted to this topic are about the item SQL Server 2022 Clusterless Distributed Availability Group
Query Plan Regressions -- - Comments posted to this topic are about the item Query Plan Regressions --
Revolutionizing Efficiency: The Power of Custom Automation Software Development - Comments posted to this topic are about the item Revolutionizing Efficiency: The Power of Custom Automation Software Development
SQL Server and AI: Integrating Machine Learning Services - Comments posted to this topic are about the item SQL Server and AI: Integrating Machine Learning Services
Has the PK been used -- - Comments posted to this topic are about the item Has the PK been used --, which is is not currently available on the site.
Has the PK been used -- - Comments posted to this topic are about the item Has the PK been used --
SQL Server 2022 - Administration
Import/Export SSMS Settings issue - I have tried a number of times to export and then import my SSMS settings as I migrate local computers or sign into new servers. But for some reason, my toolbar customization and my keyboard settings (or other Tools -> Options) settings never pass through. I always seem to get errors like this:   Your […]
FQDN - SQL cannot connect when the server name has backslash - Hi I need to connect to a SQL server via FQDN -  that is named 'ABC\ABC' If I try to connect to [ABC\ABC].mydomainfullyqualified.com it does not work. Tried many other combinations also. ABC.mydomainfullyqualified.com, all sorts of combinations. Nothing works.. If I change to a different server that does not have the back slash in the […]
Upgrading from 2012 to 2022 - Hi, Would it be possible to upgrade from sql server 2012 sp4 to sql server 2022 in one upgrade step, or would it require intermediate upgrades? Thanks for any recommendations.
SQL Server 2022 - Development
Please help to optimize the query - Hi Experts, Thanks in advance. I am new to SQL. Can you please help me in optimizing the query?   CREATE FUNCTION [dbo].[UDF_GET_REVIEWERS_INFO_FOR_COI](@awardId NUMERIC, @nomineeIds varchar(max),@phaseSettingId NUMERIC_ID) RETURNS TABLE AS RETURN SELECT ReviewerMasterCustomerId=Reviewer.MASTER_CUSTOMER_ID, ReviewerName=Reviewer.First_Name+' '+Reviewer.Last_Name, --START Nominator Centric COICount= CASE WHEN Prog.IS_NOMINATOR_CENTRIC =1 THEN (SELECT [dbo].UDF_GET_NOMINATOR_CENTRIC_COI_COUNT(@phaseSettingId,NomineeReviewer.REVIEWER_MAST_CUST_ID,1)) ELSE sum(CASE WHEN NomineeReviewer.COI_STATUS=1 THEN 1 ELSE 0 END) […]
 

 

RSS FeedTwitter

This email has been sent to [email protected]. To be removed from this list, please click here. If you have any problems leaving the list, please contact the [email protected]. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
[email protected]

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -