Author: way0utwest

  • New Database Options

    I saw recently that Azure SQL Database is getting a few more Database Scoped Options for that platform. These are intended to give more control over the way in which the engine behaves, without requiring each database on a server to function the same way. I expect to get to the on-premises product at some point, where they’ll be even more useful as we often might want different behavior for different contexts on an instance.

    While there are advantages to managing all databases in an instance in the same way, I do think that more and more we consolidate databases at times and it’s better to have additional control when needed at the database level. This week, I wonder if there are things that you wish you would have been able to specify for each individual database.

    What options would you want to see added at the database level? 

    I think that many of the options we’ve been given in current versions, as well as the newer ones appearing in SQL Server 2019 are a good start. I don’t know which instance level settings I might want here, but I certainly would like to see newer capabilities at the database level. It would be nice to see the capabilities for jobs and alerts to be set at the database level. Even if this were a part of the Agent subsystem, having the ability to keep these jobs within a database and have the agent read them would be useful.

    Moving more capabilities to the database level gives us more flexibility in separating the workloads for different applications. With the movement of the platform code, and many customers, to Azure SQL Database where the system requires less dependence on an instance, it makes sense to start including more options at the database level. I would guess that at some point most of the settings that we need for manage a system will be included and set at the database level.

    Steve Jones

    The Voice of the DBA Podcast

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

  • Fun with Savepoints–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    I haven’t spent a lot of time with savepoints, but I did find a question recently and thought I’d take a moment to dig into how they work. They are interesting, and they can be useful for you in certain situations.

    Warning: Anything involving transactions can be tricky, so be sure you test, test, test and check out how things work with a wide variety of situations, including some you might not expect.

    Here’s a basic setup. I’ll create a table to log some actions.

    CREATE TABLE TransLogger
    (ID INT IDENTITY(1,1) NOT NULL CONSTRAINT TransLoggerPK PRIMARY KEY
    , LogMessage VARCHAR(200)
    )
    GO

    Now that I have a table, let’s do something in a transaction. I’ll start a transaction, make two inserts, but set a savepoint between them

    BEGIN TRANSACTION
    

    INSERT dbo.TransLogger (LogMessage) VALUES ('First insert inside transaction')

    SAVE TRANSACTION Firstsave

    ROLLBACK TRANSACTION Firstsave

    COMMIT

    SELECT top 10
      *
      FROM dbo.TransLogger AS tl

    If I look at the results, I see this:

    2018-11-12 16_46_08-SQLQuery8.sql - Plato_SQL2017.sandbox2 (PLATO_Steve (57))_ - Microsoft SQL Serve

    That makes sense. I inserted this row (I’ve been testing, so that’s why it’s 11), and marked a savepoint with the SAVE TRANSACTION Firstsave line. Then I rollback a transaction to this savepoint, which does nothing. Finally I commit. I see my one row.

    Let’s add something. I’ll add a second item, and decide to roll it back.

    DECLARE @rollback INT = 1
    

    BEGIN TRANSACTION

      INSERT dbo.TransLogger (LogMessage) VALUES ('First insert inside transaction')
       SAVE TRANSACTION Firstsave

      INSERT dbo.TransLogger (LogMessage) VALUES ('Second insert inside transaction')
       IF @rollback = 1
         ROLLBACK TRANSACTION Firstsave

    COMMIT

    SELECT top 10
      tl.ID, tl.LogMessage
      FROM dbo.TransLogger AS tl

    Note I’ve added a variable so I can decide to rollback or not. I’d often have some condition or error handling that might cause a rollback, so this simulates that. Note that work before the savepoint is committed, but work after is removed with the ROLLBACK TRANSACTION Firstsave.

    My results are a single row. Note, I cleared the table between runs.

    2018-11-12 16_49_42-SQLQuery8.sql - Plato_SQL2017.sandbox2 (PLATO_Steve (57))_ - Microsoft SQL Serve

    Savepoints give me a place to commit work if I need it before doing more. This potentially allows me to capture some changes and not others if I don’t want to fail my entire transaction.

    Personally, if I’m doing this, I would likely just have two transactions if I can have one commit without the other.

    SQLNewBlogger

    A few minutes of experimenting gave me a quick post. I need to do more, and certainly test more, but this is a basic idea of what savepoints are. You can write something similar.

  • The Linux CoC

    This is a busy time of year for me, with lots of conferences and other events taking place. It’s busy most years, but this past October was especially busy in my life. I’ve been in New York, London, and Hong Kong during the month, which is quite a spread of time zones. It’s been a mix of work and pleasure, and I agreed to all these trips, so I can’t complain. In any case, it’s both an exciting set of trips and a daunting set, and I don’t know if I’d want to do that again.

    In my travels, I noticed some press about a new Linux Kernel Code of Conduct. This is a change from the original Code of Conflict that Linus Torvalds published. I’m not sure he adhered to his own words from the reports I’ve seen over the years about his comments to developers. In any case, he signed off, though not everyone likes the new code of conduct. I don’t know enough about the issues, but I do realize that not everyone behaves well towards others, especially in this business.

    In any case, I go to lots of conferences. I meet lots of people, and see lots of different situations play out between attendees, organizers, venues, and speakers. For the most part people are fairly well behaved and treat each other respectfully. That’s not always the case, which is why many conferences and organizations have adopted some Code of Conduct that should apply to those that attend events, are members, etc. I do think this is a good idea, as it gives us a common framework where we can evaluate behavior as well as debate future changes.

    Last week PASS has their annual Summit, with their own Anti-Harassment policy. While I haven’t observed any actions that would violate the policy, I have had friends report they have experienced these types of behavior. I’ve had friends ask for an escort over concerns of potential behavior. It’s sad that this happens in the world, but it’s a reality. I’m glad that organizations are trying to move in a direction that protects those that feel harassed or threatened.

    It’s likely that there will be overreactions, reports of misunderstandings, and similar issues. Certainly some people want the freedom to behave as they see fit, where they don’t believe they are doing anything wrong. I understand that, but ultimately I also believe that it would be better to have a few people investigated or thrown out of a conference for no reason than have others suffer because they aren’t believed. I’m here for any of you that are struggling with abuse, and I hope others are as well.

    I hope that we learn to live by the famous quote from Bill and Ted’s Excellent Adventure: be excellent to each other. If some of you can’t do that, then at least learn to live by Wheaton’s Law.

    Steve Jones

    The Voice of the DBA Podcast

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

  • Fundamentals

    Volleyball season is approaching. Practice started last week for the team that I’m coaching this year, and I’m excited. I look forward to teaching and competing with a new group of athletes each year. I’ll also look forward to a more regular schedule and a bit less traveling for a few months.

    In preparation for this season, I’ve been doing some learning, some reading and watching, trying to improve my abilities, something I’ve done for a few years. One of the books I completed recently was one on John Wooden and called Wooden: A Coaches Life. This was a look at his life, as player and coach, with some of the descriptions and principles that embodied his work as a college basketball coach.

    There were interesting stories and topics in the book, but one of the core items emphasized in the book was Coach Wooden’s emphasis on the fundamentals of the game. He stressed this with his players, asking them to work on the basics and perfect them more than on any complex plays or situations. I tend to focus on the basics when I coach as well, hoping to train players to be good at their jobs, trusting them to react to new situations.

    This feels like advice that is applicable to a data professional as well, especially in the era of new features and functions that continually expand on the capabilities of the Microsoft data platform. While graph structures and containers and Azure Data Factory and Big Data Clusters are amazing new technologies, there is still a need to have good, solid fundamental skills for a SQL Server system. We still expect anyone working in those areas knows how to backup a database, how to write good T-SQL, how to set security for objects, and more.

    If you want to specialize, that’s great. Perhaps you love BI or HA or some other aspect of working with the SQL Server data platform. Just keep in mind that the fundamentals are important, no matter what your job. You ought to be very competent at handling any of those tasks that we would teach a junior DBA in their first year on the job. Once you know those, you can move on to more specific items. If you don’t know those, be sure you include those as part of your learning along with more niche topics.

    Steve Jones

    The Voice of the DBA Podcast

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