On Being a Workaholic

I recently posted on Facebook that I was a workaholic and that fact wasn’t going to change anytime soon because I was having such a great time. Today, I read this article talking about programmers’ work ethics driving them crazy to the point that they can no longer work. The article points to two factors: the imposter syndrome and the “real programmer” mentality, discussed recently on Reddit.

The imposter syndrome has convinced those of us affected by it that we are not as good as our peers. I have to say I am very guilty of this, but every once in a while I realize that I am trying to compare myself to the most brilliant folks in the business. There is no point in doing that. I’m never going to be as good as Andy Leonard at SSIS, Itzik Ben Gan at T-SQL, Kalen Delaney at internals, Stacia Misner at SSAS… and on and on and on. I’ll never be as good as they are at their specialties, but I do have skills and good qualities. Well, sometimes I think I do. SQL Server is a GIGANTIC product. If there is a person who has mastered all of it, he or she has yet to come forward. But still, this self-doubt is the source of much anxiety for me.

 ball and chain     The second issue is the “real programmer” mentality. This means that real programmers love their work so much that they spend as many waking hours as possible coding. Or, at least to be seen as a “real programmer” where they work, they must be ready to work insane hours, weekends, nights – whatever it takes. I also suspect that some developers are somewhat addicted to coding, similar to video games. I know it is hard for me to step away when I am “in the zone.”

Right now, at Pragmatic Works, I am consulting 40 hours a week. I don’t get called on weekends. I’m not expected to work late hours. It’s pretty nice. I have been in a job that I felt tethered to and had to be reachable 24/7. When a big project, like a merger, came up, we were expected to work almost every weekend and to not take any time off for months. I have to say that eventually, I got burnt out and had to get away. My former colleagues are still putting up with this.

So, why did I say I was a workaholic if I am only putting in 40 hours a week consulting? Well, a lot of my time outside of work is spent writing, developing presentations, learning new skills, or actually presenting. I spend about 20 hours a week on those activities. These extra-curricular activities are what I really love to do right now, and I do think that my community activities are important. Besides being what I love to do, they are benefitting many people who learn from me.  There are so many people who need help learning SQL Server and other technologies. If people like myself did not produce this content, how would they learn? Not everyone can be an author or a speaker. Not everyone can be a leader.

So, of course I spend time with my family. I have three sweet grandchildren (and one more on the way!), and I try to be a pretty cool grandmother. I love getting outside to walk or ride my bicycle. I get together with my sisters and brothers for Karaoke nights. I also have “no computer” weekends from time to time. Yes, I guess I am a workaholic, but I am having a ton of fun doing what I love to do.

Posted in Life in IT | 2 Comments

Which Join Operator Will My Query Use?

There is so much to learn about SQL Server that I am both enthusiastic and overwhelmed when I think about it.  Of course, depending on what an individual likes to do, some things will be easier for them. For example, I would trust Itzik Ben Gan with my life if it depended on writing a T-SQL query. But I wouldn’t expect him to be the same level of guru on SSIS or SSAS.  (Maybe I am wrong here; he is brilliant and might be an expert on those technologies, too.)
For me, the joy of working with computers is creating things. Maybe that thing is a report or an SSIS package or a T-SQL query. When I was a developer, before focusing on SQL Server, I did a lot of consulting work for very small businesses. The question was frequently “Can you give us a button that does <fill in the blank>?” and more often than not, answer was yes. I loved that I could figure out how to automate processes and make a small business more efficient.

Since I love creating things so much, sometimes it is the process of creating something more than the internals that interest me. I read a lot about internals, but the details don’t always stick with me as much as I would hope they would.
One topic area that just kept dropping out of my brain are the three types of joins: Hash Match, Nested Loop, and Merge Join. Within a 48 hour period, I had two opportunities to explain when each of these would be used. In one case, it is for a book chapter I am working on. In the other case, a mentee of mine asked the question. They say the best way to learn something is to teach it to someone else, and this is a great case in point.
Without going into how each of the three join operators work, I can tell you when they will be used for inner joins.
Nested Loop
A nested loop will be used when one of the inputs is estimated to have less than 10 rows. Here is a query for the AdventureWorks database that should utilize a Nested Loop:
SELECT SOH.CustomerID, SOH.SalesOrderID,  C.* FROM Sales.SalesOrderHeader SOH JOIN Sales.Customer C ON SOH.CustomerID = C.CustomerID WHERE SOH.CustomerID = 11000;


The cluster key for the Sales.Customer table is CustomerID. The Sales.SalesOrderHeader has a nonclustered index on CustomerID with no other key columns or included columns. Since the WHERE clause limits the Sales.Customer rows to just 1, a Nested Loop is the choice.
Merge Join
If both inputs are estimated to be 10 or more rows, and the inputs are sorted on the join columns, then a Merge Join will be used. This query should use a Merge Join: SELECT SOH.CustomerID, SOH.SalesOrderID, C.* FROM Sales.SalesOrderHeader SOH JOIN Sales.Customer C ON SOH.CustomerID = C.CustomerID;
This query is just like the first except that it is missing the WHERE clause. The same indexes are used, but this time all of the customers are required, not just one. Since the number of rows involved are over 10 from both sides and the input is sorted on the joining column, the Merge Join is selected.
Hash Match
If both inputs are estimated to be 10 or more rows and one or both of the inputs are not sorted by the join columns, then a Hash Match will be used. Here is a query that uses a Hash Match:
SELECT SOH.CustomerID, SOH.SalesOrderID,SOH.OrderDate, C.* FROM Sales.SalesOrderHeader SOH JOIN Sales.Customer C ON SOH.CustomerID = C.CustomerID
This query looks just like the previous query except that an extra column has been added to the SELECT list from Sales.SalesOrderHeader. Because this column is not part of the index on CustomerID, the Sales.SalesOrderHeader’s clustered index is used instead. The clustered index is sorted by SalesOrderID, so it does not meet the requirements for a Merge Join.
So, I guess this means I need to write another post soon that drills into how these work under the hood. Stay tuned…

Posted in Internals | 1 Comment

My New Site

Welcome to my new site where I will post blogs on a weekly basis about SQL Server. My favorite aspect of SQL Server is T-SQL. Even while being a DBA for eight years, I have always been a developer at heart. I love to write about T-SQL, SSRS, SSIS and High Availability. I have just started using SSAS and moving more to the BI side of things, so expect some posts on those topics as well.

Posted in Life in IT | Leave a comment