SQL Saturday RVA

SQL Saturday RVA is just under two weeks away and we have been busy trying to get everything in place.  I have had a great team with Wayne Sheffield (b|t) and Geoff Johnson (t) doing some heavy lifting.  Our event will be at the University of Richmond, hosted by the school for continuing studies.  Tammy Alexander has been wonderful to work with and has opened a couple of doors where we thought we had hit a dead-end.

I thought I was familiar with the work required to pull off an event like this; however, it has been a challenge.  PASS has been wonderful and it has been nice to work with Karla Landrum (t).  Our event opened about 6 months ago and I am glad we did, we needed almost every day of it.  I am unsure how some of these events can go up in less than 3 months.

If you are planning to attend the event, I am sure you will have a good time.  We have a great speaker lineup and it continues to amaze me that people will give up their weekend to come and help others learn.  I am excited about being at the University of Richmond and I hope the area we are in fosters conversation and networking.    We will have several items to raffle off and some of our sponsors have free items for every attendee!  I hope to see you there.

Posted in SQL Saturday | Leave a comment

My Experience on SQL Cruise

Oh Yeah!

Oh Yeah!

Of the great aspects of the SQL Server community is the willingness of people to share what they know as they discuss resolutions to problems they face.  There are a variety of opportunities to engage these people–blogs, user groups, SQL Saturday, the Summit, and there may be a few I am not aware of; however, I can say that none of them are quite like a SQL Cruise.  I’m glad I found it–SQL Cruise is the real deal.

I did not, at first, consider SQL Cruise to be right work/play model.  I had not been a cruise before and I wasn’t sure what to expect.  My track record shows I tend to do things on the cheap and cruising screamed expensive–at least to my ears.  The price of the training itself was another concern as I would be paying for the training out of my own pocket.  While Tim Ford (blog|twitter) is a recognized name in the community, I hadn’t met him nor had I met the other speakers.  A self-proclaimed people person, I needed a connection and that connection came in the way of Wayne Sheffield (blog|twitter), who attended the Alaska 2012 cruise.  I met Wayne at the Richmond SQL Server users group and had attended several of his SQL Saturday and user group sessions.  Wayne gave it his seal of approval and after my wife and I agreed the numbers would work out, we booked our ticket on the SQL Cruise.

The Cruise

After conference activity area

After conference activity area

As a first time cruiser, I was pleasantly surprised by the whole experience and would go again.  If I was not part of a conference, a seven day cruise might be a little long; however, there is plenty to choose from to occupy yourself on board.  As a frequent foreign traveler, I enjoyed chatting with the staff about where they were from, what locations we had been to in common, and where they enjoyed going on the Islands.  Everyone was extremely friendly and when I found out they worked 10 hours a day, 7 days a week for 9 months I was super impressed.

Upward and Onward!

Upward and Onward!

Being in the Caribbean was very nice and I had not traveled to that part of the world before.  I was surprised how many Spanish speakers there were on the islands and many had lived and worked on the different islands their whole lives.  Again, one to do things on the cheap, I had purchased a Lonely Planet book beforehand and we went to several local places to get a better feel for life on the island.  On St Thomas of the Virgin Islands, we boarded a local bus and I struck up a conversation with a high school student.  I asked him what he call US citizens from the ‘mainland’–his response: “tourists”.  :)

Beaches in St Maarten

Beaches in St Maarten

Favorite Island treat: French pastries on French side of St Maarten
Favorite Island Activity: Snorkeling on St Johns.
Favorite Island memory: Traveling back to the Cruise Ship with Big Joe, his son and Jason Brimhall (blog|twitter), his wife and my wife.  We had taken local transportation and no one, even me, was sure we were headed the right direction until we could actually see the cruise ship.  We shared the bus with several high schools students.

Chris Bell(blog|Twitter) is detailing his adventures on his site for a better day by day feel.

The Training

Cruise Schedule

Cruise Schedule

You do, after all, sign up for SQL Cruise because of the training and the technical presentations, given in two hour blocks were very good; however, they are what you would expect at any SQL Saturday. I did learn something new in each session and I have a notebook with pages of writing to prove it.  The real value came in less structured settings called office hours.  In those sessions, I would could ask ‘my’ questions to either a single person or the group I happened to be with at the time and get different viewpoints.  We all know there are a million different ways to do the same thing and I personally valued getting different opinions.  In preparation for the cruise, I made a list of some of the areas I was struggling with or needed help with and asked them.  Some were discussed in front of the whole group and I was a little nervous about being labeled a ‘stupid question asker’, but then I realized I was with the SQL community and EVERYONE was willing to help.

Getting my learn on!

Getting my learn on!

Not all of the training is technical in nature.  Most, if not all, of the attendees have been DBAs for 5+ years and like me, have good technical skills.  Many are looking to expand the nature of their work and it was fascinating to discuss the paths they traveled.  For instance, talking with Tim about his experience of going from developer to DBA to then organizing SQL Cruise and talking with Neil Hambly (blog|twitter) about how he got his job with Confio showed me there are multiple ways to find fulfilling work in our field.

(Possible) Favorite Training Moment: The class reaction when Kevin Kline opened the execution plan I submitted for the Execution Plan contest.  The collective grown in the room let me know I wasn’t  going crazy.
(Possible) Favorite lesson learned:  Office Hours discussion on communicating with management.  See Takeaway #4.

The Takeaway

There are lots of little things I took away from the experience.  I have areas I need to improve in, some I knew before the cruise, and I have the following plan based my experience on the cruise.  In no particular order

  1. Become proficient in PowerShell.  This goal is really about being comfortable with the PowerShell language to the point I can begin to administer my environment in it.  I would like to begin collecting server data/stats about the different environments and having that in a central place.  Phase II would be to create my Minion (You should have been there)–a repository of metadata that each system uses to perform admin functions. IE the backup location is in this table and an update to it would affect the next backup job cycle.  I ordered “Learn Windows PowerShell 3 in a Month of Lunches” to start me in this process.
  2. Implement policy based management.  I have been bitten more than once by a ‘standard’ setting that was different on this one server.  There are several ways to implement this; however, I just need to start.
  3. Master the execution plan.  As an attendee, we all received a copy of Grant Fritchey’s “SQL Server Execution Plans” courtesy of Red Gate .  As the winner of the SQL Sentry’s Hairy execution plan contest, I received a copy of SQL Sentry’s Execution Plan explorer Pro.  No specific session focused on this; however, I realize I need to place a little more effort in reading execution plans and now I have some awesome tools to do it with.
  4. Create a management report that allows them to easily see the health of the SQL Server.  This is not the same type of report a DBA would want to see, just the number of executions per second and how long those executions are taking with some history for comparison.  Stretch goal–make it available to the SQL Community in a way users can easily deploy and use.
  5. Go on another SQL Cruise.  I would hop on the Alaska cruise in a minute, but my schedule won’t allow it this year.  I would surely enjoy chatting with Buck Woody and the others, but I will have to take a rain check and check out the 2014 offerings.

As an aside note, I went on the cruise with my wife and she had a great time as well.  If you can swing it, I recommend bringing the spouse along.  Beside the technical sessions, everyone has the opportunity to get together and we enjoyed getting together with the other family members.  My wife now has a few more Facebook friends she might also meet on the SQL trail.  It was a great time and I am glad I had the opportunity to go.  I would recommend it to anyone.

Tim posted some great photos on his site.  Check them out!

Posted in Conferences, I learn something new everyday | Tagged | 5 Comments

SQL Server en Español

While I was born in the United States, my father is from Costa Rica and it was always a little weird being the only Carlos Chacón that didn’t speak Spanish–especially because I am the oldest on my dad’s side.  Luckily the rebellion of my youth didn’t entirely destroy my opportunity to learn Spanish as I spent two years in the Provincia de Buenos Aires (Buenos Aires Province) of Argentina as missionary for my church in the late 90′s.  !Aguante Lanus!

I have a goal in 2013 to start making presentations in Spanish and until now, never had a need to install SQL Server in anything but English.  Written translations are a bit tricky, but didn’t give two seconds thought to the SQL Install untill I came across this . . .

SQLLanguageInstallError

My first presentation will hopefully be in Costa Rica this April at a SQL Saturday so I had set all my language/local settings to there.  Turns out, SQL Server en Español want Spanish from the motherland-Spain.  Setting the language to show option and the region option to Spain did the trick.  Now on to translate my slide decks . . . .

Posted in Presentations, SQL Saturday | Leave a comment

SQL Saturday 173 Washington DC

Saturday December 9th found me in Washington DC for SQL Saturday 173.  As we are planning an event in Richmond, I opted to volunteer more than I have in the past so I could be closer to the logistics and see what the organizers had done. #SQLSat173 was organized by Chris Bell, a first time organizer, with a little assistance from his wife.  :)

I knew putting on a SQL Saturday took a lot of work and the DC team put it all together nicely.  While the content of the sessions would make most attendees happy, the DC team provided a few extras to give the attendees lots of reasons to enjoy themselves–there was food all day long, a Microsoft Kinect in the lobby, a hot lunch from Maggiano’s, and they had a Kindle Fire raffle for those that printed their speedpass.  The DC team had wonderful sponsors that helped most of that possible and I hope to the RVA team can replicate some of that–with our own twist of course.

The DC team provided vests as a thank you to the speakers and volunteers.  Here I am sporting mine.  :) VestOh course, I did make it to several sessions and I had a great time.  My dad actually tagged along and enjoyed himself.

The one other treat was meeting with Karla Kay and chatting with her about some of the ideas we had for our event.  As always, the SQL community is wonderful and I hope to see you out on the trail!

Posted in Uncategorized | Leave a comment

Coalesce instead of Max

I was asked to tune a query which was used in an export of registration data. A person registers for an activity and they answer questions about this. This query pulls from 19 tables–one of which is a one to many. The export creates a column for each row in the many table. It is on this subject I would like to focus.  For simplicity, I have reduced my examples to two tables. My setup looks something like this.

QuestionAnswerSetup

The tsql below will create this. Our end goal is to match the questions answered by each registrant to the registration data.

CREATE TABLE Registration
( RegID    INT
, RegistrantFirstName    VARCHAR(25)
)
INSERT INTO Registration (RegID, RegistrantFirstName)
VALUES (1, 'Carlos'),
(2, 'Wayne'),
(3, 'Jeff')

CREATE TABLE RegistrationAnswer
( RegID    INT
, RegQuestion    VARCHAR(25)
, RegAnswer    VARCHAR(25)
)

INSERT INTO RegistrationAnswer (RegID, RegQuestion, RegAnswer)
VALUES (1,'Favorite Color','Red'),
(2,'Favorite Color','Blue'),
(3,'Favorite Color','Red'),
(1,'Favorite Food','Pizza'),
(2,'Favorite Food','Chimichangas'),
(3,'Favorite Food','Hamburgers')

The previous logic used the Max() Function to break the rows into column. Seemed to work well.

--Old Way
SELECT Registration.RegID, RegistrantFirstName, Answers.*
FROM Registration
LEFT OUTER JOIN (SELECT MAX(CASE WHEN RegQuestion='Favorite Color' THEN RegAnswer ELSE null END) AS [Favorite Color]
, MAX(CASE WHEN RegQuestion='Favorite Food' THEN RegAnswer ELSE null END) AS [Favorite Food]
, reg.RegID
FROM [dbo].[Registration] reg
INNER JOIN [dbo].[RegistrationAnswer] ans ON reg.regid = ans.regid
GROUP BY reg.RegID) Answers ON Answers.regID = registration.regid;

I found; however, that if I commented out the left outer join portion of the query (Remember, the real query has 19 tables) the export will suddenly become very fast. With that in mind, I began to look for ways of moving rows to columns and came across an example using the coalesce function. The result is the following. I use a CTE to get the records from the many table and then I use the coalesce function with my group by, replacing the max function.

--New Way
WITH Answer_CTE (RegID, RegQuestion, RegAnswer) AS(
SELECT RegID, RegQuestion, RegAnswer
FROM RegistrationAnswer
)

SELECT Registration.RegID, Registration.RegistrantFirstName, Answers.*
FROM Registration
LEFT OUTER JOIN (SELECT RegID
, coalesce(min(case RegQuestion when 'Favorite Color' then RegAnswer else null end),'') as [Favorite Color]
, coalesce(min(case RegQuestion when 'Favorite Food' then RegAnswer else null end),'') as [Favorite Food]
FROM Answer_CTE cte
GROUP BY RegID) answers ON Registration.RegID = answers.RegID;

What was the impact? I turned on Statistics IO and Statistics TIME ON and got the following results. I ran each of them several time so I could get everything set (load into memory, cache plan, etc). These results are from the query I was tuning.  For readability purposes, I removed the read-ahead reads, lob logical reads, lob physical reads, and the lob read-ahead reads as each were zero for both queries.

Old Query

SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms,  elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms,  elapsed time = 0 ms.

(1357 row(s) affected)
Table ‘Worktable’. Scan count 0, logical reads 0, physical reads 0
Table ‘two’. Scan count 1, logical reads 6896, physical reads 0
Table ‘three’. Scan count 1, logical reads 56069, physical reads 0
Table ‘four’. Scan count 3, logical reads 4628, physical reads 0
Table ‘five’. Scan count 2, logical reads 10090, physical reads 0
Table ‘six’. Scan count 0, logical reads 0, physical reads 0
Table ‘seven’. Scan count 0, logical reads 4165, physical reads 0
Table ‘eight’. Scan count 0, logical reads 4520, physical reads 0
Table ‘nine’. Scan count 1489, logical reads 9299, physical reads 0
Table ‘ten’. Scan count 0, logical reads 4569, physical reads 0
Table ‘eleven’. Scan count 0, logical reads 3, physical reads 0
Table ‘twelve’. Scan count 0, logical reads 2, physical reads 0
Table ‘thirteen’. Scan count 1, logical reads 35, physical reads 0
Table ‘fourteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘fifteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘sixteen’. Scan count 335, logical reads 720, physical reads 0
Table ‘Worktable’. Scan count 0, logical reads 0, physical reads 0
Table ‘seventeen’. Scan count 335, logical reads 721, physical reads 0
Table ‘eighteen’. Scan count 1, logical reads 22, physical reads 0
Table ‘nineteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘twenty’. Scan count 1, logical reads 100039, physical reads 0

SQL Server Execution Times:    CPU time = 13093 ms,  elapsed time = 20205 ms.

The query ran in almost 20 seconds. The only change I made was to the CTE and the coalesce function instead of Max SQL Server parse and compile time:

SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms,  elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms,  elapsed time = 0 ms.

SQL Server Execution Times:
CPU time = 0 ms,  elapsed time = 0 ms.

(1357 row(s) affected)
Table ‘Worktable’. Scan count 2714, logical reads 10947, physical reads 0
Table ‘two’. Scan count 0, logical reads 13422, physical reads 0
Table ‘three’. Scan count 1357, logical reads 17500, physical reads 0
Table ‘four’. Scan count 2, logical reads 8680, physical reads 0
Table ‘five’. Scan count 2, logical reads 10090, physical reads 0
Table ‘six’. Scan count 0, logical reads 0, physical reads 0
Table ‘seven’. Scan count 0, logical reads 4165, physical reads 0
Table ‘eight’. Scan count 0, logical reads 4520, physical reads 0
Table ‘nine’. Scan count 1489, logical reads 9299, physical reads 0
Table ‘ten’. Scan count 0, logical reads 4569, physical reads 0
Table ‘eleven’. Scan count 0, logical reads 3, physical reads 0
Table ‘twelve’. Scan count 0, logical reads 2, physical reads 0
Table ‘thirteen’. Scan count 1, logical reads 35, physical reads 0
Table ‘fourteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘fifteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘sixteen’. Scan count 335, logical reads 720, physical reads 0
Table ‘Worktable’. Scan count 0, logical reads 0, physical reads 0
Table ‘seventeen’. Scan count 335, logical reads 721, physical reads 0
Table ‘eighteen’. Scan count 1, logical reads 22, physical reads 0
Table ‘nineteen’. Scan count 1, logical reads 2, physical reads 0
Table ‘twenty’. Scan count 1, logical reads 100045, physical reads 0

SQL Server Execution Times:    CPU time = 5797 ms,  elapsed time = 7196 ms.

This query ran in just over 7 seconds. Because these are exports and are not always in memory, I have found that there is larger discrepancy in the elapsed time the first time each query is run. For the purposes of comparison I ran them each multiple times before taking the stats.

Posted in I learn something new everyday, Scripting | Leave a comment

Emailing the operator

Not sure why I just now stumbled into this but . . . . I learn something new everyday.  :)

You set up a SQL agent job and want to be notified when it fails, so you click on the Notifications option for your job and select the email option.  NotificationsYou have already set up DatabaseMail–that works, you set up your operator and it is enabled and has a 24×7 schedule (Déjà vu perhaps; know someone else with that schedule?).  You are all set and know you will be notified when the job fails.  The next day you check your job–not because you got an email, but you just want to see the green check mark of success and instead you see the red x of rejection with this in the details–
NOTE: Failed to notify ‘DBA’ via email.

Say what??  It appears there is one additional step.  Right click on SQL Server Agent and click properties.  On the Alert system option, click the Enable mail profile and choose the profile you set up for DatabaseMail.  Restart the SQL agent, and voilà you start getting emails.  Well, hopefully not too many.  :)

AlertSystems

Posted in I learn something new everyday | Tagged | Leave a comment

SQL Saturday 168 Tampa Florida

Saturday November 17th found me in Tampa Florida for SQL Saturday 168, a BI focused conference.  I have had limited opportunities to work in the BI space so I was anxious to learn more and see what the learning curve would be.  I have a client that would like to do BI project and I wanted to see if I could get a better idea of what it would take.  My family and I had been vacationing in Florida that week and I almost considered cutting our trip short and not going–I am glad I went.  It was a good event.

The presentations were good, but they were ALMOST overshadowed by the food!  They had a homemade spread of chicken, rice, beans and veggies and it was excellent.  My conference attendance is somewhat limited, but this was hands down the best food I have eaten at a conference.

My big take aways from the conference were

  1. Self service BI is pretty cool.  The new tools in Excel, DataViewer, and SSAS and pretty need and I hope to be able to get more access to these tools.
  2. Big data is not as scary to me now as it was before the conference.  I was concerned about all the focus on big data and how that would affect me as a DBA.  There is still quite a bit of ramp up; however, it was to my great surprise that Adam Jorgensen said you could be up and running on https://www.hadooponazure.com/ in 2 hours and change.  Course, I haven’t put that statement to the test yet, but let’s just say it is on my to do list.
Posted in SQL Saturday | Leave a comment