Tag: sql server

  • It Starts with Version Control

    As a software developer, I learned about the value of version control over time. My first forays into development were as a child, where I made a single backup of my code on a separate floppy disk in the event I had an issue. This was my one-man-wolf-pack version control system, and it served me well, although it wasn’t efficient. In a few of my early development positions, we zipped up all our code each night to a separate folder, giving us the pentagram-version-control system. This worked as long as we didn’t need to go back over a week, but it still wasn’t very efficient. I think that because we worked on fairly small projects and could hold most of the code in our minds, we muddled through issues.

    Later I was introduced to a real version control system (VCS), Visual SourceSafe. Some of you cringe, but that system worked well. We could see the differences in code, and over time I learned to cut loose with my development, just trying new things, knowing that I could easily revert code backwards without much effort. Since then I’ve worked a bit with Subversion and Git, both of which seem to be very capable, mature systems. I still plan on getting some work done with Mercurial and TFS at some point, just to compare the features and functions.

    I started source controlling my databases after reading an article by Bill Wunder. This was over a decade ago, and it seemed to make sense to me. All of the things I had learned about VCS worked with databases as well, and I learned that having a database under VCS provided me with some stability in development, including the ability to roll back to previous versions of code when we found bugs. Trust me, checking out a previous version of a stored procedure is much, much less stressful than restoring an old backup just to look at stored procedure code.

    These days I see more and more people putting their databases under version control, which is comforting. It makes me think that we, as data professionals, are maturing in our industry. However there are still lots of people out there that don’t use a VCS for their database (DDL) code. Some don’t even use a VCS for their application code.

    There’s no excuse these days. Subversion and Git are free and open source. Download them, spend a few days, and get control of your code. All of the ways in which you can improve the efficiency and quality of your software start with more knowledge, and a bit of version control on which to apply your craft.

    Steve Jones

    Video and Audio versions

    Today’s podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music. Support this great duo at www.everydayjones.com.

    Follow Steve Jones on Twitter to find links and database related items and announcements.
    Steve Jones Windows Media Video ( 23.4MB) feed

    MP4 iPod Video ( 27.2MB) feed

    MP3 Audio ( 5.7MB) feed

    Feeds are available at iTunes and Mevio

    To submit an article, rant or editorial,
    log in to the Contribution Center

  • How SQL Server Full Backups Work

    I’m writing this in support of a few talks I give that talk about backups. This is how I see things and it’s based on things I’ve learned over time. Some of this comes from a great explanation on Technet from Paul Randal, but there are misc other sources that I can’t be sure of which ones I’ve used. Long story short: I learned most of this from others and docs. It’s not all me.

    There are two parts to a full backup in SQL Server:

    • data reading
    • log writing

    Technically both sections read and write, but this is how I think of things. I’ll describe there:

    Data reading – The backup process goes through all extents allocated and reads a page, sends it to a buffer and that gets written to the backup file. This happens as fast as SQL can do it, just going through the pages, but it takes most of the backup time.

    Log writing – all of the log records that are written while the data reading portion of the backup is running are appended to the backup file, after the data pages.

    Let’s say that the entire time of the backup, from the File Created to the File Last Modified timestamps on the backup file is represented by t. The data reading portion of the backup takes time d. The log writing portion of the backup takes time l.

    This gives us:

    t = d + l

    My database is transactionally consistent at backup start time + d, not + t. When is that? I’m not sure, but usually it’s fairly close to the timestamp at the and of t.

    Make sure that your backups are transactionally consistent. Don’t export, don’t use open file managers, don’t use anything that doesn’t respect transactions. The native SQL Server backup process does this. If you want a few other features, my employer makes SQL Backup Pro, which also respects transactions.

  • Transactionally Consistent

    What does this mean? I had someone ask me in a session recently, and I think I have a good explanation, but I thought this was worth a blog.

    Transactionally Consistent means that there is a snapshot of the database at a point in time that ensures committed transactions are actually reflected in the database and uncommitted transactions are not. I haven’t found a better concise definition, but Paul Randal has a great longer explanation.

    This is reflected in the ACID RDBMS model as the C for consistent.

    In a SQL Server backup process, this is accounted for by including some amount of the transaction log in the full database backup. The amount included depends on your workload and the amount of data you back up, and if you read Paul’s explanation, you’ll understand more.

    Make sure that your backups are transactionally consistent. Don’t export, don’t use open file managers, don’t use anything that doesn’t respect transactions. The native SQL Server backup process does this. If you want a few other features, my employer makes SQL Backup Pro, which also respects transactions.

  • Project Hekaton

    If you haven’t heard about Hekaton by now, you should think about reading up on it. There’s some information from TechNet, a keynote video, and more. Despite the ranting from Oracle’s Bob Evans in 2012 that this was “vaporware”, it’s coming in SQL Server 2014. The latest demos don’t show 100x increase in query speed, but they 30x or so numbers I’ve seen are very impressive.

    Hekaton is an in-memory database technology, actually called In-Memory OLTP in Books Online. This isn’t a re-invention of the pintable concept from SQL Server 2000. Instead it’s a very well though out architecture and rather interesting in the way it’s implemented. The keynote video gives you a deep overview, though to use the tables, most of us don’t need to know the internals of how they work.

    However we do need to look at the restrictions, err requirements. Since these tables will exist in memory, obviously you need more memory, but more than you thought. The recommendation is twice the expected table size, to account for versioning. In addition, this memory is in addition to the buffer pool and other memory your instance already needs. That means much more complex memory calculations and monitoring for DBAs.

    The complexity of SQL Server continues to grow over time as more and more features are added to the product. Many of us don’t need much more than the core relational database functionality for many applications, but the in-memory OLTP tables might be one feature that can help dramatically increase the speed of your application.

    Steve Jones

    Video and Audio versions

    Today’s podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music. Support this great duo at www.everydayjones.com.

    Follow Steve Jones on Twitter to find links and database related items and announcements.
    Steve Jones Windows Media Video ( 15.3MB) feed

    MP4 iPod Video ( 18.1MB) feed

    MP3 Audio ( 3.7MB) feed

    Feeds are available at iTunes and Mevio

    To submit an article, rant or editorial,
    log in to the Contribution Center