Author: way0utwest

  • Common SQL Server Mistakes – Shrinking Databases

    I don’t like there being an easy command to shrink databases, and I especially don’t like seeing the shrink option as a part of the default maintenance plans.
    However it seems that this technique for managing sizes is used quite often, and even given as advice by some people. A few comments about this feature:
    First, don’t regularly shrink databases. Actually, don’t shrink databases at all if you don’t understand what it does. Paul Randal, who managed the storage engine team, wrote a blog about why not: Here’s a good reason not to run SHRINKDATABASE. The bottom line is that this fragments your indexes, which raises reads and decreases performance.
    If you are concerned about space usage, you have two choices: add less data or buy more space.
    SQL Server database files aren’t like a Word or Excel file. They don’t allocate space on disk as it’s needed. Well, they do if you have autogrow turned on, but really the files and server expect to have free space in the data files for data growth, change to data (and potential page splits/new extent allocations), and for maintenance.
    If you rebuild indexes regularly, and you ought to if they become fragmented, you need free space in your server. An index rebuild copies the entire index to a new, un-fragmented set of pages, and then drops the old index. So you need double your disk space for rebuilds.
    Managing space proactively is something you should do, and that means that you want to leave a pad inside your data files to allow for data growth. If you don’t have enough disk space, buy more. You need the space for data, and for performance.

    Transaction Log Files

    Now the transaction log files are a slightly different story. You still want to size them correctly, and some good reasons from Mr. Randal on this. You should set your log file size based on the frequency of your backups. The backups are scheduled based on your risk tolerance. Basically, more frequent backups, less transaction log space needed.
    However regularly shrinking your log files doesn’t introduce fragmentation, but it is dumb. Maybe not dumb, but it’s a waste of resources. Your server needs a t-log file size of xx to handle the regular activity on your server. Shrinking it at night and having it grow the next day to handle load is silly. And a waste of disk writes.
    Set your log file, manage it as needed, don’t shrink it.

    When to Shrink

    So should you never shrink? No, you can shrink, but the feature there is for emergencies or one-time events. If I get a load of 500GB on my 1TB data once a year, I might get crazy log growth. I might plan for that by expanding my log in advance, and then shrinking the log afterward, back to the size that I normally use.
    The same thing could occur in a database. Perhaps you move some data to a read only db and want to get the space down to data + largest index. Then you can shrink, rebuild indexes, and leave the log there. You can’t shrink to just data without fragmenting, so don’t try.
    When you shrink, use SHRINKFILE, and target specific files, for a specific reason. Not as part of regular maintenance.

  • More Than SQL

    SQL Saturday #52I am speaking at the upcoming SQL Saturday #52 – Colorado in the Denver Tech Center in a little over a week. I’m doing a presentation on The Modern Resume and a short mini-keynote talk at lunch time, and I’m joined by some amazing speakers, like Kevin Cox from the SQL CAT team, User group President Marc Beacom, and local MVPs Glenn Berry, Paul Nielsen, and Chris Shaw. We have some amazing people coming from out of town like Jack Corbett from Florida and Tim Mitchell from Texas, and Jason Strate from Miinesota. It’s a fantastic lineup with many more talented speakers and the chance for you to get a free day of world class training on things important to your career as a data professional.

    Those of us speaking are doing our part to give back to the SQL community, which is an amazing group of people that not only strive to be better at their jobs, but also engage and interact with one another, sharing that knowledge. I’ve learned a lot from many of these people, and hope that I can teach a little bit as well.

    However at this SQL Saturday, we are giving everyone the chance to do more than just learn about SQL. You can give back to this local community as well. We will be accepting donations of food that speakers will distribute back to the community food banks and victims of the fire near Boulder in Four Mile Canyon.

    There is more to life than our work. The SQL community is here to help you with your career, and we are happy to do that. This is a great way of also looking to give back to the local community in a way that I hope catches on at other events.

    Steve Jones

  • SQL Saturday #52 – Colorado

    I will be speaking at SQL Saturday #52 – Colorado in a little less than two weeks. I am giving my presentation of The Modern Resume and also doing a short talk at lunchtime on your career and trying to move forward. Hopefully it will go over well and if you’re not interested, take lunchtime to network with a few people. Either new contacts, or old ones, but take advantage of the time to meet with people outside of an office and talk some shop or career.

    There is a fantastic lineup of speakers, including a few highly respected speakers from out of town. Jason Strate ( LinkedIn | Blog | @stratesql) , Tim Mitchell (LinkedIn | Blog | @Tim_Mitchell), and Jack Corbett( LinkedIn | Blog | @unclebiguns) are coming from other states, as far away as Florida to give you some amazing training.

    From the local community, we have Chris Shaw ( LinkedIn | blog | @sqlshaw), Marc Beacom (LinkedIn | @marcbeacom), Carlos Bossy (LinkedIn | blog | @carlosbossy), and more.

    The event is on Sept 25th, and here is some information:

    8:00am – 5:00pm – Feel free to come a few minutes early to get registered and then network with other professionals from around the area

    Cherry Creek Presbyterian Church
    10150 E. Belleview Avenue
    Englewood, CO 80111
    sqlsat52

    This is just E of the Denver Tech Center, near Cherry Creek State Park and slightly SE of Cherry Creek High School.

    Hope to see you there!

  • Technical People Should Blog

    I ran across a great blog titled: Post 300 or why all developers should be blogging. The reasons given in the articles are great, and I think they apply to all technical people.

    You will learn by blogging, and you will keep stuff in a place that you can go back and review it, in addition to giving you something to impress interviewers. There is one more big reason, however.

    You need to communicate.

    I don’t think I’ve ever seen a position that didn’t require some type of communication skills. You might not need to get up in front of a group and express things (or you might), but almost everyone needs to document things or communicate through an electronic written medium. It could be email, IM, texting, some forum system, or anything else. However you need to communicate.

    The more you build these skills, the better off you will be. There are definitely some very talented people that can get away with poor social skills and poor written skills, but that’s not most of us. Most of us need to communicate effectively.

    To me, blogging is like typing. A developer that hunts and pecks with two fingers is not likely a good developer. And certainly they’re not an efficient developer.

    The same thing comes from communicating. You need to practice it to get better at it. You don’t need to write as much as me, or write as long a posts as I do, but by writing regularly, you’ll learn to better express yourself.

    (cross posted to The Modern Resume)