Editorials

Bias

How do we protect ourselves from our own biases? That’s a loaded question. What I am doing here is a little soul searching regarding my own personal biases where I have found that things I held to be truth were no longer accurate. Here are a few things that I have found changed over time.

In SQL Server using the syntax

SELECT …

INTO #Temp

is really cool because it creates a temporary table matching the schema of the executed query without using a transaction. As a result, this query is REALLY, REALLY fast. It both creates and populates a temporary table in a single step.

In older versions of SQL Server this practice was discouraged. The reason was that when you executed this query it would place a lock in tempdb so that no other process could create a temporary table until your select statement completed. If the query was long running, nothing else could create temporary tables in tempdb for the duration of the query. As you can see, that is bad. So I continued to use this syntax carefully for a couple of years after Microsoft had resolved the issue.

Another practice we used to follow was breaking out stored procedures into smaller units. The reason for this was to simplify things, sometimes. However, the more specific reason was based on how the query optimizer functioned. If you had a stored procedure that would branch based on if you were doing an update or an insert, the procedure would compile again each time you went down a different branch. Again, Microsoft made changes where the query optimizer can create a new plan for portions of a stored procedure rather than the whole thing. This has dramatically changed how we need to write procedures to get optimal performance.

Here are some observations I have from these two scenarios and others like them. First, I find it helpful to research what has changed as a new version of software I am using is released. Second, I can’t keep up with software changes. So, I have found it easier to not try and be an expert anymore. I’m always a student, and it doesn’t matter who I learn from. More than once I have had a novice programmer show me something that works which I was certain was wrong.

That doesn’t mean that I don’t have an opinion anymore. It means I have a tendency to do a little research before being dogmatic. There are some principles and practices that have been proven. Those I tend to hold onto with more energy. But, when it comes to what software does, and how to use it, things change so fast today, a bias can be your enemy.

Does this strike a chord for you? Share your thoughts in our comments.

Cheers,

Ben