• Skip to main content
  • Skip to primary sidebar

DallasDBAs.com

SQL Server Database Consulting

  • Services
  • Pocket DBA®
  • Blog
  • Testimonials
  • Contact
  • About

Kevin3NF

Stories from the HealthCheck – part 2

January 8, 2020 by Kevin3NF Leave a Comment

This week I am highlighting the top items that I see on almost every SQL Server I run across that need to be changed in almost every instance.

Number 2:

CheckDB

I’ll give you a little leeway on this one, despite how rampant it is. I get that many of you have never heard of database corruption.

Its a thing.

Its a bad thing

Its a potential data-loss thing! (that got your attention, yeah?)

If your database(s) get corrupted, Microsoft’s standard answer is to restore from your last non-corrupt backup (see yesterday’s post).

Things you should be doing:

  • Set your Page Verification level to Checksum
  • Set up a recurring job to run DBCC CheckDB against ALL of your databases (SQL has built in tools for this, or use Ola Hallengren’s FREE scripts)
  • Turn on alerts for Errors 823, 824, and 825
    • Make sure an email goes to someone that knows how to respond to these errors

Corruption can come from a number of places.

  • Storage subsystem – common
  • Bad versions of SQL Server – less common – patch your servers.
  • Funky Code situations – much less common
  • Other – no, I’m not going to list every possible option, lol

If you do all this and then get that dreaded email or alert from your monitoring tools – read this article before you do anything else.

Now go Check your CheckDBs.  Now.  Go.

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: HealthCheck, SQL

Stories from the HealthCheck – part 1

January 7, 2020 by Kevin3NF 1 Comment

This week I will be highlighting the top items that I see on almost every SQL Server I run across that need to be changed in almost every instance.

Number 1 by a landslide:

Backups

We’ve been backing up SQL Server in the same way since at least SQL 7.0 from the late 90’s, yet…there are so many bad or missing backup plans:

  • No backups at all
  • Backups to the same drive as the databases
  • Backups to the same server as the databases
  • Backups with irregular frequency (manual?)
  • Production databases with no transaction log backups (so no ability to restore to a point in time)
  • VM backups only, and once a day at best

Every one of these exposes you to data loss that is probably very unacceptable to your customers.

If you think that because you are in the cloud, or have a great SysAdmin/Infra team you are covered, let me give you two reasons to completely re-think your strategy:

  • User error
  • Ransomware

Your expensive HA solution will not save you from accidentally deleting a table.  Ransomware can bankrupt a small business.

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: HealthCheck, SQL

T-SQL Tuesday 121: Gifts

December 10, 2019 by Kevin3NF Leave a Comment

T-SQL Tuesday is a monthly blog party for the SQL Server community. It is the brainchild of Adam Machanic (b|t) and this month’s edition is hosted by Mala (b|t) who has asked us to write about “Gifts received this year” – which is appropriate for the last month of the decade!

So…many…gifts!

Aside from faith, family and friends which are the truest gifts in my life, I had a fantastic year, SQL Server-wise.

In somewhat order:

  • Dallas DBAs is doing very well and will hit a record for sales in 2019!
  • We hired Jeff and he’s been great…
  • SQLDork continues to contribute and learn every afternoon…
  • Got to go to Summit again this year!
  • SQL 2019!
  • New clients helping me pay Jeff and the Dork…
  • Ellipses, bullet points and exclamation points went on sale…!
  • On-site sponsor at SQL Saturday Cincinnati, Dallas and Austin!
  • Existing clients that trust us with their data and projects…
  • 2 freelance DBAs that I can offload small projects to!
  • New prospects for 2020!!!

I could go into lots of detail on each…but nah…go read some more T-SQL Tuesday posts!

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: SQLSaturday, Summit, TSQL2sday

The Story of Jeff

November 21, 2019 by Kevin3NF Leave a Comment

Jeff level enthusiasm, Image by zoegammon from Pixabay

Jeff (b|t) and I have been friends since sometime in 2003. He was the worship leader at my church at the time. Most recently Jeff and his wife have been running a graphics design firm. Websites, book covers, textbook layout, WordPress development, etc.

Earlier this year when the graphics biz was slumping he asked if I needed any help at Dallas DBAs. After some discussion I offered him a 3 month apprenticeship – full time at offensively low hourly rates. I would be teaching him and letting him self-teach through whatever means he could get his hands on.

Inside that 3 months he was already getting on customer servers and doing daily checks (with my guidance of course).  We have a process for this.

He currently has primary DBA responsibility for 5 hourly clients and one Pocket DBA™ client, escalating to me as necessary.

As of this month, Jeff’s efforts are driving enough billable hours that he is COVERING HIS ENTIRE SALARY!  SQL Dork (b|t), the other Junior DBA here has been self-covering for a long time due to only working part-time.

I would like to tell you all of the steps Jeff took along the way…but he already blogged the whole trip.

For your reading pleasure:

The Ironic DBA Files

  • Prequel: The Ironic DBA—Starting a New and Unexpected Career
  • Episode 1: You Back That Up?
  • Episode 2: Attack of the Corruption
  • Episode 3: Revenge of the Index
  • Episode 4: A New Primary Key
  • Episode 5: The Maintenance Plan Strikes Back
  • Episode 6: Return of the TSQL
  • Episode 7: The Backup Awakens
  • Episode 8: The Last Rebuild
  • Episode 9: Rise of the Clients
  • Review One: A SQL Story
  • It’s Hip to Be Square
  • Rock Around the Clock
  • Failure is Always an Option
  • Back to Basics

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: Accidental DBA, Apprentice, Beginner, Career

Duplicate Indexes Explained

November 13, 2019 by Kevin3NF Leave a Comment

What are duplicate indexes, and why do I care?

This is an entry level explanation, with an analogy for new DBAs.

Duplicate indexes are those that exactly match the Key and Included columns.  That’s easy.

Possible duplicate indexes are those that very closely match Key/Included columns.

Why do you care?

Indexes have to be maintained. When I say that, most people immediately think of Reorganizing, rebuilding and updating statistics, and they are not wrong.

But..don’t overlook the updates that happen to indexes when the data changes in the columns they are based on. If you have a duplicate index and you add, change or delete a row…BOTH of the indexes are changed. This takes CPU, memory and log space to do.  Magnify by multiple indexes across a databases with tables that have millions or billions of rows and you start feeling this effort.

Duplicates:

Consider the following two indexes:

-- DisplayName only
CREATE INDEX [NC_DisplayName] ON [dbo].[Users]
	([DisplayName] ASC)
GO

--DisplayName plus additional info
CREATE INDEX [NC_DisplayName_Includes] ON [dbo].[Users]
	([DisplayName] ASC)
INCLUDE ([Reputation],[CreationDate],[UpVotes],[Views]) 
GO

If you query the StackOverflow database for me (Kevin3NF) using

Select DisplayName
From Users
Where DisplayName = 'Kevin3NF'

It will use the first index *

If you add ‘Upvotes’ to the Select, it will use the second index.

So…how is this a duplicate index?

The Key column (DisplayName) is the same.

Drop the NC_DisplayName index, and your first query will use the second index because even though there are 4 additional columns, the Key column is still there and this index is better than a table scan.

You also get the benefit of not having to update NC_DisplayName any time data is changed.

An Analogy of Two Doors:

You have two doors:

The First door is simple.  It has one aspect to it…a handle.

The Second door has a handle, as well as all sorts of Included extras.

Both doors lead to the same place.  Assume some people like the simplicity of Door1 and some people really want to go through the Steampunk style Door2.  Both get what they want (destination), by picking the door that suits them.

If you take away Door1 (Drop Index), the folks that prefer it can simply go through the fancy Door2 and get where they needed to be. Door2 has included extras (columns) that the “Simple door” folks just ignore.

It really is that simple.

But…don’t go make an index with all possible columns!  That’s a whole different kind of bad indexing.

Now…this does not mean you need to go blindly dropping indexes.  Research, test, verify which indexes are being used/unused, etc.  Definitely don’t go and drop a Primary Key index just because its a possible duplicate.

I use sp_BlitzIndex for my initial info gathering when doing HealthChecks, Index Tuning, etc. Its free and solid.

Video:

* I have run into a weird issue I am trying to sort out. In my testing, it appears that SQL Server might be basing its index decisions on the Index Creation date, all other things being equal. I will update as I find out more. This was done on SQL 2016, SP2 with the StackOverflow public data dump.

Per my good friend Pinal Dave (b|t), this is a known behavior: ” if two index has same key columns the one created later is used.”

Go forth and research!

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: Accidental DBA, Beginner, Indexing Strategies

T-SQL Tuesday 120: What Were You Thinking?

November 12, 2019 by Kevin3NF 2 Comments

T-SQL Tuesday is a monthly blog party for the SQL Server community. It is the brainchild of Adam Machanic (b|t) and this month’s edition is hosted by Wayne Sheffield (b|t) who has asked us to write about “What Were You Thinking?” – things we have seen that left us scratching our collective noggins.

The list is long, so I’ll just go with something I saw yesterday.  And in September. Both created by a full-time DBA at a client.

BACKUP LOG MyDatabase
TO DISK = 'E:\SQLBackups\MyDatabase.trn'
WITH INIT

Yep.  It runs hourly.  And initializes the .trn file each time. Goodbye Point in Time recovery.

Ick.

Bonus points: Duplicate indexes, which I will cover in a future post.

Thanks for reading!

Kevin3NF

Follow @Dallas_DBAs

Filed Under: backup, TSQL2sday, Uncategorized

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 15
  • Go to page 16
  • Go to page 17
  • Go to page 18
  • Go to page 19
  • Interim pages omitted …
  • Go to page 44
  • Go to Next Page »

Primary Sidebar

Search

Sign up for blogs, DBA availability and more!

Home Blog About Privacy Policy
  • Home-draft
  • Blog
  • About Us

Copyright © 2026 · WordPress · Log in

 

Loading Comments...