Author: way0utwest

  • Daily Coping 5 May 2021

    I 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. All my coping tips are under this tag. 

    Today’s tip is to walk a different path outside today.

    You could take this literally or figuratively today. Maybe you want to change the way your life goes today, but for me, this was a literal new path.

    When I walk, it’s usually a specific path like to the mailbox or using a trail near the house. Today I decided to try something different. I don’t walk the property enough, but I took the dogs and made a loop around, checking on fence, and just enjoying a different environment in life today.

    I do try this figuratively as well, thinking about our outside life here from my wife’s perspective. How she looks at horses and our property, the things she’s concerned about. I try to put myself in her place, to better understand why she does some things and what’s important.

    It helps me cope by not focusing on my issues.

  • Holding Code in Your Head

    It is hard to write software. Many of us write lines of code, and often if we go back, we find flaws and problems in our code. As I look at the solutions others might give for the same problem, I’m sometimes amazed at the way they tackle the problem and what language features they use. I’m especially always intrigued when I see someone using STUFF() or APPLY in their queries. I know I have a bit of a hole here, as I haven’t done enough work with them in my career. It’s a tool I just don’t think to reach for.

    Part of that is that I don’t know I completely understand how they work in my head, at least not without effort. The lack of familiarity hurts me here, but it’s part of the issue that Paul Graham expresses in this essay about holding a program in your head (essay via Brent Ozar).

    I certainly have held entire programs in my head, and when I do, I think I work a little more efficiently. Certainly faster, and I can change things as I refine the solution I’m aiming for. I also find that when someone else is touching the code I’m working in, even lightly, it is distracting. The differences in reading my code vs. someone else’s are noticeable.

    I think this is where working in a team, unless you are pair/mob programming, can be challenging. While discussing issues with others might help find solutions, I do think that groups need to subdivide code into sections and allow each person/pair/mob to work on that code alone for a period of time. Some organizations do this well, but plenty do not.

    Perhaps one of the best reasons to be careful about touching the same code in a database is the last writer wins. While some tools might work with the code in memory on your workstation, many of the ways we capture and track T-SQL code come from the database itself. If multiple people change the same object in a shared database, we can easily lose code or frustrate programmers seeing strange behavior.

    There are a number of items that Mr. Graham thinks will help programmers write better, or more, code. However, I also think that his problem space is focused more on startups and new applications rather than the legacy code on which many of us work on every day. However, I do take the point that having a more succinct language might allow a programmer to hold more in their head and get more done.

    If they’re are intimately familiar with the language itself. I think that is a skill managers should promote in teams. And something I need to work on with STUFF and APPLY.

    Steve Jones

  • Daily Coping 4 May 2021

    I 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. All my coping tips are under this tag. 

    Today’s tip is to laugh at something today or make someone laugh.

    I love comedy, and going to see a show is something I’ve missed during the pandemic. However, comedians are still making recordings and telling jokes, and I’ve enjoyed some of their efforts this past year.

    I also like hearing or saying something humorous in the family. We all mis-speak at times, or we make a comment at the right time that gets everyone laughing. I’m not good enough to do it on demand, or consciously, but it does happen regularly with some of us.

    Verbal, text, the right gif at the right time, I’ve had a few good ones lately that get my wife or kids to laugh, and after seeing this tip, I stopped to appreciate the humor in my world a few times and be thankful we can still laugh at things.

  • Static Code Analysis Feedback for Operations with SQL Monitor

    One of the challenges with managing a production database is that the code that gets deployed sometimes causes lots of problems. Often a production DBA or sysadmin gets called about problems that they didn’t cause, and can’t necessarily fix.

    Helping developers learn what the impact of their code is, and if it is following good practices, is something many of us would like to do, but often don’t have the time, or a good report that we can easily pass on.

    I saw recently that the SQL Monitor team had deployed a new feature to the product that makes this a bit easier. They have incorporated the code analysis from SQL Prompt into SQL Monitor, which you can see at  https://monitor.red-gate.com/overviews/sqlmon-vmw-bm.red-gate.com/cluster/workload01.smdemo.local/sql/demo#?Zoom=1619213137440%2C1619220337440&MaxTime=1619220337440&Present=true

    I’ve linked to one of the workload demo systems being monitored. If you look at the top 10 queries, and pick one, you’ll see something like this:

    2021-04-23 17_26_30-demo - Server Overview — Mozilla Firefox

    Just below the query text, there is a blue lightbulb (for a new feature) and the text: SQL Monitor has identified 2 issues with this query. Addressing them could improve performance.

    Clicking the link gives you the issues. In this case, these are code smells that I’d want a developer to address. Having a TOP without any ordering could confuse clients, but it also might mean we are gathering the wrong data, since there isn’t a guarantee on which 10 rows come back.

    2021-04-23 17_26_41-demo - Server Overview — Mozilla Firefox 

    You can screen shot this, or send this link to developers, and ask them to fix this code for the next deployment.

    SQL Monitor has become an impressive product over the years, and with multiple teams adding to it now, it is constantly evolving to meet the needs of our customers. If you haven’t tried it, consider an evaluation before you purchase a monitoring tool (or before you build one).