Author: way0utwest

  • Saving Hard Dollars

    This week I ran across an analytics piece that talks about how Big Data and analysis can do more than help marketing, it can also create hard dollars for your company. Companies are using sensors and technology for mundane tasks, but tasks that can save the company substantial, hard dollars.

    You may have heard of UPS and FedEx optimizing their routes, and tracking the actions of drivers. Those companies (and others) have learned that a little programming work to analyze and create instructions for their workers can reduce wasted time and fuel, which ultimately means less wasted money. Other companies have reduced their heating or cooling costs with more data and small investments.

    I don’t know how many additional cost reductions can take place in most companies, but there are likely changes none of us have thought of that could be easily implemented with technology. It seems like a no-brainer that technology can build better routes, but early on, it wasn’t considered as an option because it didn’t replace a formal manual process. It wasn’t worth paying someone to design routes each day for a truck.

    As computer power increases, and more data becomes available, I predict that we’ll find many ways to analyze that data and change the way we run businesses. Many of the ideas will be unexpected, and some may be counter-intuitive, but those of us working with data will have a front-row seat to the ways in which data analysis can transform our world.

    Steve Jones

  • The Decline of SQL Server

    For many years in my career, SQL Server was the runner up. Both Oracle and DB2 were in much wider use and more popular among all sizes of companies. Serious applications used one of those platforms, according to many technologists, the DBAs on those platforms made more money, and most companies were willing to pay for the software. That changed, and over the years I’ve seen SQL Server grow close to Oracle, while DB2 has declined (and MySQL has grown). Here’s the 2014 chart from Gartner, on of all places, the MySQL site.

    I see other charts and reports, showing various percentages, so it’s hard to be sure where things stand. Many of them agree that for total market share, it’s still Oracle and DB2 (mostly on larger hardware), but SQL Server rounds out the big 3. However is that the case for jobs and opportunities? I read a piece from Thomas Kejser that pointed out that the popularity of SQL Server may be declining (there’s also an update).

    I see lots of jobs posted, and so many companies using SQL Server. SQL Saturdays continue to have great attendance, so I wanted to ask you this week:

    Is SQL Server being used less, or are other platforms being implemented, in your experience?

    Are you seeing a trend away from new, or additional, SQL Servers in your organization? I haven’t heard of any large trends, though I certainly do know that some organizations are considering other relational platforms. I think that’s healthy and expected. The technology for managing transactions is well known, and I think that all three major platforms, as well as MySQL and PostgreSQL are maturing to the point that any of them can handle the load for most applications out there.

    I think it’s only natural that other platforms will be used to solve problems that they are well suited for. However just as I don’t think SQL Server will grow to dominate the RDBMS space, I don’t think that NoSQL platforms will dominate over RDBMSes in many applications.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 2.9MB) podcast or subscribe to the feed at iTunes and LibSyn. 

  • Testing your API

    I think learning to better test our software, including the database objects, is one of the ways in which we’ll build better software applications in the future. Testing is a complex subject, but this is part of a series that looks at ways in which you can use tSQLt.

    Checking Table Metadata

    One of the easy tests you can write is to compare the meta data of an object to a known quantity. The easy way to do that in tSQLt is to use the AssertResultSetsHaveSameMetaData function. This function compares the structure of two result sets, covering names, ordering, and data types, to determine if they are the same.

    Here’s a quick example of how that’s done.

    Let’s assume I have this table:

     create table Articles  (
        [ArticlesID] [int] identity(1,1) not null,
        [AuthorID] [int] null,
        [Title] [char](142) null,
        [Description] [varchar](max) null,
        [Article] [varchar](max) null,
        [PublishDate] [datetime] null,
        [ModifiedDate] [datetime] null,
        [URL] [char](200) null,
        [Comments] [int] null
      );

    If I wanted to write a test in tSQLt to check this table for changes or alterations, here’s what I’d do in code:

    create procedure Articles.[test Articles_Check_metadata]

    as

    begin

      –Assemble

    create table Articles.Expected

      (

        [ArticlesID] [int] identity(1,1) not null,

        [AuthorID] [int] null,

        [Title] [char](142) null,

        [Description] [varchar](max) null,

        [Article] [varchar](max) null,

        [PublishDate] [datetime] null,

        [ModifiedDate] [datetime] null,

        [URL] [char](200) null,

        [Comments] [int] null

      );

     
      –Act

     
      –Assert

    exec tsqlt.AssertResultSetsHaveSameMetaData

      @expectedCommand = N’select * from Articles.Expected’,

      @actualCommand = N’select * from articles’

      ;

    end

    ;

    go

    Note that I don’t have an ACT section in this test.

    The Assemble section is easy. I record the size and shape of my table. This will be what I compare the actual table to in the database.

    The Assert section is a call to AssertResultSetsHaveSameMetaData, with a SELECT * from the real table being compared to the same SELECT from the expected result table I created. If these match, I pass the test. If they don’t, the test fails.

    Why?

    This seems silly, I know. What does it matter if the table changes, and it certainly will need to change. I definitely questioned the value of a test like this when I first saw the example. However when I thought about it, and thought about the places in which I’ve developed databases, this makes some sense.

    Imagine that I have 3 or 4 (or more) developers. As we get new requirements, we’ll change the schema over time. Imagine that I actually have views built on this table, and other procedures and functions, all of which have some tests on them. If I change this schema, and run a test suite, I could see multiple failures. If I did that, one would hope I realized that the addition of a column here (or a rename) would cause those issues. However if I changed a couple things before running a test, which is something I might do at times, having this test fail tells me quickly that the schema was altered. If someone else changed the schema, I also quickly see that this change was to the schema.

    It’s not a big change, but it does allow me to determine that I need to refactor all the objects (potentially) that depend on this table. I can go do that work now, or add it to the list of tasks for this particular development task, and also fix the tests, which should go quickly.

    If the work doesn’t go quickly because I have a lot of objects, then I’m really glad that I learned now this is an issue.

    This becomes even more valuable with views and procedures returning result sets. If I add a column, then I may or may not want views to change, but certainly a check of view meta data will tell me if they do.

  • The Final Service Packs

    There was an announcement recently that Service Pack 3 for SQL Server 2008 R2 was released. This is the final SP for that version and is mostly a rollup of all the previous cumulative updates (CU), though there are a couple additional items included.

    This is good news, and if you are running the “R2” version, I’d test this and install it. No more CUs will be released, though you’ll want this SP installed in case additional security patches are released during extended support. The last thing you’ll want is a crisis situation where you need to install a security patch based on SP3, and you haven’t tested this update.

    Earlier this year, Microsoft announced that we’d get one last SP for both SQL Server 2008 and 2008 R2. That was good news as many people are running these versions, and they haven’t installed all the previous CUs. I can understand this situation, and it would be good to bundle all the changes together in one final patch for companies that find the platform suits their needs. It’s also a fair request for customers that paid Microsoft for  a platform and should receive all patches developed during its lifecycle. Including a final patch that closes out support.

    I’m still waiting for an SP4 for SQL Server 2008 and I hope we get one soon. I’m not sure what the plans are for SQL Server 2012, 2014 and future releases, but I’d like to continue to see the bi-monthly CUs, an annual SP, and a final SP when each version transitions from mainstream to extended support.

    Steve Jones

    UPDATE: SQL Server 2008 SP4 was released just after this was written. It is available here: http://www.microsoft.com/en-us/download/details.aspx?id=44278

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 2.3MB) podcast or subscribe to the feed at iTunes and LibSyn. feed