Author: way0utwest

  • Using WAITFOR to Test Slow Code–#SQLNewBlogger

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

    One thing I needed to do lately was test how a calling program would respond to slow code. I decided to use a normal query, but add a WAITFOR() to simulate different delay levels. However, I had to look up the syntax for the call and I decided to blog about it.

    WAITFOR DELAY

    The WAITFOR call isn’t a function. I’ve written about that before. Instead, this is listed as a control-of-flow element in the language.

    I have a rough idea of how this works. I use

    WAITFOR DELAY

    as the basic syntax. SQL Prompt helps me here, since looking this up is a pain and slow. I know there is a time element in here, but I always worry I’ll pick the wrong time and then sit for a long time testing.

    The key is this format: hh:mm[[:ss].mss]

    To delay for 2 minutes, I write this:

    WAITFOR DELAY '00:02:00'

     

    That gives me what I need, and using a string variable, I can control this delay programmatically.

    SQLNewBlogger

    This is a good example of learning a piece of code and writing about it. Short, simple, show how this one works in T-SQL. Add the why, show some code, and results. How you use it, and what you learned.

    This was a 10 minute post.

  • Jumping Air Gaps

     

    There are all sorts of viruses, worms, and malware out in the world, and some of us have had to deal with them at different points in our career. SQL Slammer was particularly memorable for me, but there were plenty of non data related virus issues I’ve had to work on at various employers.

    To keep sensitive information safe, many high security environments have built air-gapped computers, where these systems aren’t connected to a network, or at least not a general network in an organisation, and certainly can’t access the Internet. At home, you could think of this as an older computer with no network card, or even a spare laptop with a broken network radio. To get information to/from this computer, you’d use some sort of removable media.

    Apparently there are concerns about malware being able to jump this air gap, using the removable media. Nothing terribly new here, as infected USB sticks have been a concern for years, but this appears to be a twist and apparently the malware waits for a chance to send information off to a receiver.

    If your system is truly air gapped, then there might not be a way for this information to be ever be copied, but what if that isn’t the goal. Imagine ransomware uses this technique and infects database backups. If you have an offline place for backups, could a copy of a new backup infect other backups? With separate tapes this isn’t an issue, but if you use some sort of part-time connection to move data, this could be an issue.

    I’m always wary of online backups or even live copies of data. I know many large systems find tape unusable and impractical, but I know that having physical copies of tapes ensured some level of security for my backups.

    The creativity of malicious actors and the threat vectors they devise are scary and incredibly hard to guard against. I don’t know what the best solution is for data and database backups, but I certainly hope that someone smarter than me is working on the problem.

    Steve Jones

    Listen to the podcast at Libsyn, Stitcher or iTunes.

  • Daily Coping 27 May 2020

    I’ve started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here.

    Today’s tip is to do something special today and revisit it in your memory tonight.

    I’m going to pick something that I did a few weeks ago, but it was special to me. That night it was something I revisited, and even today, I’ve rethought about it a few times.

    In graduate school, I rowed crew. For a year I was in an 8 man boat before I left to start my career and switching to a 4 man boat with some other older professionals. For three years, I rowed 3-4 times a week, mostly on the water. In the winter, I used a Concept 2 ergometer in the gym, and eventually bought one for home.

    Rowing was the hardest sport I’ve ever been involved in. It’s hard, and tiny changes across every stroke add up to big changes across thousands of meters. I was in the best shape of my life when rowing every week. Over time, I used the machine less and less and it became a basement decoration.

    During the last year, I’ve regularly gone to the gym for yoga, swimming, and weight lifting. I have used a stationary bike at home when I’m pressed for time. I used it during the initial weeks of the pandemic, but I wasn’t getting quite enough work in. I saw a few friends on Instagram and Facebook had been rowing regularly and even started a rowing challenge. 10k a day average for May. Do 9k one day, need to do 11k the next.

    I’d never rowed 10k on land in one sitting, topping out at 5k most of the time in my sessions. I started rowing again a couple times a week, trying to force myself to work harder. I did some 3ks, then some 5ks, and even tried some countdowns from 30:00 minutes (usually getting in about 6700m).

    One day I decided to take some advice from a friend and not aim for my old 2:00/500m pace from college. I’d been struggling with 2:03-2:05 paces mentally, and someone suggested I try pulling a 2:20/500m instead. I tried it, but after a few minutes, I was struggling to go that slow. Instead, I found a 2:08 pace was fine, and I switched after a couple minutes to a 2:10/500m goal. That’s easy to mentally compute on my 25 year old pace tracker.

    As I went along, I got to 5k at a bit over 20 minutes and I decided to push further. I kept the pace, only slowing slightly as I got to 7k, then 8k, then 9k. I finished with a bit over 10k.

    20200515_170901_HDR

    A personal best, a lifetime best, and something that felt very daunting to me. I haven’t gone 10k again, but the 5k rows have been easier. I’ll do another 10k again soon, with more confidence than I had the first time.

  • Enriching Your Life

    As I was looking to build career goals for the new year, I think mostly about technical topics. That makes sense, given my focus and job, but I ran across an interesting thread on Hacker News that asked about skills to work on in 2020, and not necessarily technical ones.

    I did find it interesting that one of the first comments was self improvement, and quite a few comments on cooking, both as a skill to learn and a way to save money. There are plenty of comments on other non-technical skills, but since this is a technical site, I wanted to focus there.

    We’re over a third of the way into the year, and we’re dealing with a pandemic. Business is slow, many people have lost employment, and it’s possible many more will. Fewer companies are hiring, so there is a need to stand out more if you find yourself looking for a new job.

    With that in mind, what types of things would you work on if you knew you’d need a new job by the end of the year. Let’s say that you have seven months to prepare to look for a new job on Jan 1. What would you work on?

    Leave a comment and let us know today.

    Steve Jones