What it took to stump the optimizer

Sometime ago I was working with a Microsoft support technician on a ticket related to some database issues on SCOM. The technician wanted to run a stored procedure to clear out some of the backlog we were seeing with a batch job.

When he ran the procedure (via Query Analyser) – we encountered an error as below. Basically an error that is wee bit rare, the optimizer telling us that it is stumped and the query is too big for it to process. The technician moved on to other ways of resolving the issue as fixing this problem involved touching some procedures that came with the product and was beyond the scope of our call. But after we were done, I was intrigued to find out what caused the optimizer to give up.scomoptimiser

I went to Line 177 of the specified stored procedure and found a statement that looked pretty small on the outside:

DELETE dbo.[CategoryOverride]

FROM dbo.[CategoryOverride] CO

JOIN #BaseManagedEntitiesToPurge BMETP

ON CO.[InstanceContext] = BMETP.[BaseManagedEntityId]

The table CategoryOverride had about 300 rows..and  on checking what went into the temp table – it wasn’t all that large either, only around 100 rows. Looking at the estimated plan from the optimizer gave me nothing – a perfectly ordinary plan with an equijoin on a clustered index. So what was causing the problem?

I looked to see if the table CategoryOverride had any triggers on it. None. Then I went on to looking at keys. The table had one foreign key defined on it.

scomo1

I decided to script this key and see what it showed me.

ALTER TABLE [dbo].[CategoryOverride] WITH CHECK ADD CONSTRAINT [FK_CategoryOverride_ManagementPack] FOREIGN KEY([ManagementPackId])

REFERENCES [dbo].[ManagementPack] ([ManagementPackId])

ON DELETE CASCADE

GO

There was my culprit – an ON DELETE CASCADE. So many other tables is this touching? A quick look at the dependancies on this table showed me no less than 14. For one record to be deleted – there were dependancies on 14 tables. I picked one record on the main table and counted how many dependant records were there to clean up. It was about 6000. So the delete statement was far from a benign straightforward delete – it had a huge amount of data to clean up and the optimizer could not generate a plan across 14 tables some of them having more cascade deletes on them.

Moral of the story – never assume the simplicity of a statement based on looking at it, or what the query optimizer tells you. The truth may be much deeper. If I had the choice of fixing it I would remove the cascade delete and go on to cleaning up data step-by-step in each of the dependant tables.

TSQL Tuesday #61 – Giving back

This TSQL Tuesday is hosted by my friend Wayne Sheffield. The topic is on ‘giving back’..what do you think you can ‘give back’ to the sql community in the upcoming year?

When I was new to this country – I had a friend who was a psychotherapist by profession. Towards the holidays – when everyone took time off, went shopping, decorated homes and so on – she would be working double , sometimes triple shifts. She worked for herself, so nobody really made her do this. But it was the time when business boomed for her. More people were depressed and low towards the holidays causing more therapists to be in business. Now, I come from a country with a lot of poor people. Seeing more people depressed instead of happy during a festive season was news to me – but that is topic for another post. The point as she explained to me was that the need to give without adequate self nourishment made a lot of people feel very depleted and as a result, depressed and low. In some ways , our small community is also reflective of the bigger outside culture – we expect people to give more and more – volunteers need to do more, the people on PASS board need to do this and that, MVPs and friends who are doing well need to recommend jobs…on and on. What are we doing to ensure appreciation and self nourishment within our community?

I don’t mean prepping people up or tweeting about how much we love each other and so on , although those things are important. I mean things like looking out for someone who is out of work. If you find any opportunities that he/she may be interested – let them know. Put in a word of recommendation, if you can do it. Share your own stories, not just of successes, but of failures. Like the time when a technical interview was really hard and you knew in 10 minutes that you were a poor fit. Or the time when you wondered how having 500+ linkedin contacts is not leading to any successful job leads. Or when everyone is talking of the sqlserver job market booming and there is nothing remarkable happening in your neck-of-the-woods. We all have times like that. Sometimes, sharing those stories is the best thing we can do to help someone who is depleted. As I write this, I know of 4 people who are looking for work. They are all smart, hardworking, caring individuals who have given to community and are in need of self nourishment. My goal is to be there for them in whatever way I can. And for people like them, in the year to come.

User Group Funding: Twitter Chat summary

I was part of a very interesting chat on twitter on how to find funding for user groups and SQL Saturdays. The conversation was initiated by Brent Ozar with an RT of Andy Warren’s blog post stating that running chapters is a lot of hard work. It was followed up with an active discussion on funding and how to find more funding to support chapters, particularly smaller ones. Those who participated include – Brent Ozar, Grant Fritchey, Kendal Van Dyke and Andy Warren. Matt Velic and me added our thoughts also. Following are some interesting observations.

On funding for small groups:

Me: ‘Funding for small groups has become inconsistent after UGSS and Idera pulled out of consistently sponsoring.’
Kendal: ‘Ideally that’s where SQLSaturday activities can help fund the group for the year.’
Matt: ‘SQL Sat would have to charge a fair amount to fund for a whole year’.
Brent: ‘Charge $25 for SQLSaturday,still the deal of the century’.
Andy:’Hard to justify cost/effort/reward for small groups if you’re a sponsor. Have to find ways to change that’.
Kendal: ‘Having a marketing plan, good look/feel, consistent messaging – all help bring in more sponsors.’
Grant:’ Fact is, small UGs suffer. I know. Trick is, minimize your needs, don’t emulate big groups.’

On topics and speakers:
The topic deviated to if or finding big-name speakers was important or as important as topics. I spoke to my experience that big names draw big crowds – at user groups or sql Saturdays. Others chimed in as below.

Brent:There’s less of a “celebrity” factor in the SQL community than folks think.For most attendees, local presenters *are* stars.
Andy: ‘Topic matters as much, or more.’
Grant : ‘ Another vote for more. Topic wins huge. I’m seeing that more & more.’
Grant: ”Fight like heck to get big name speakers, even if it’s just remote.’

On drawing bigger crowds of people :
We had some debates on quality versus quantity of people. Charging a fee might mean fewer people but draw those who are really interested.
Brent – ‘Vendors want quality too, not just quantity’.
Grant – ‘Speaking as a vendor, we want quality, but let’s face it, quantity has a quality of it’s own.’

Everyone agreed that Andy had done a great job with Orlando SQL Saturday and also with blogging consistently on these issues. We look forward to more posts and guidance from him (with other thoughts and ideas also). as we move forward into the next year.

 

 

TSQL Tuesday #60 – Something new learned..

This TSQL Tuesday is hosted by my good friend Chris Yates – the topic is on something new learned in the recent past. It is a simple topic but can sometimes be hard to articulate. I am a big believer in an open mind and learning anything new that comes my way – and have learned that the older you grow the harder this can be. The one practical lesson I claim to have learned, finally, in the recent past – is to sell myself and my work better. Or..to put it in other words, that publicity for what you learn and do is as important as the work itself.

I grew up in a culture that did not think too well of people – in particular women, being very extroverted. That combined with the fact that I was home-schooled for health reasons did not make me a huge extrovert by nature. My good friend Kevin Kline once did a survey of geeks and explained that most people who take to computers in a big way are, in some ways introverted. I don’t think being introverted has anything to do with self esteem, or even being shy or anti social. I just think these are preferences around how we are – that we prefer quality company over numbers, and are somewhat deliberate in our thoughts and actions. I do think though that it does impact how we sell ourselves – or publicise our work. For someone to know you you need to get out there and show them who you are – or it is more likely that those people who know far less than you do and drum up their work better will get the right chances to get ahead.

In my 13 years of attending the PASS Summit – I have always tried to spend time in classes, attending the occasional evening party. This time, I did something different. I spent most of my time networking – hanging out in community zone, asking people if they’d like to do lunches or dinners where we shared each other’s cares and concerns, and introducing myself to many SQL celebrities I had only known by name. I found the experience very rewarding – I got a lot of insight into options for career advancement, upcoming trends and changes in nature of work (more telecommute, more data analytics, more ‘unlimited’ vacation…) – not to mention the emotional support from a  huge number of #sqlhugs. I was selective, of course – in some ways, like I have always been. I usually hang with people whom I feel are genuine at some level, not just all about fluff, and are intuitively easy to relate to. That is something that I will want to keep.

My good friend Grant Fritchey once remarked  to someone who was a very strong techie and yet very humble and unassuming – ‘you need to be more assuming’ (he meant that you need to sell yourself more/better). That , in one sentence has been what I learnt recently – to be more ‘assuming’ while being true and genuine, at the same time.

PASS Summit 2014 – People to meet

I am late writing this…between getting ready to take one week away from work, things to pack and keep the home in a reasonably tidy shape there was no time to blog. But I have been gathering thoughts in my head as I went by doing my chores – on whom to meet and what to do. This is my summit #14 in a row, and have never ever regretted coming back here because of the friends I make and the connections that enrich me in every way.

1 Whom to meet – I am one of those many people who learnt the hard way that the community that matters the most are those in your own neck-of-the-woods – people who work at companies nearest to you, volunteer at your sql Saturdays and user groups and so on. So my very first preference is my breakfast with the team from Louisville – I know several of them already and most do not have a blogging or tweet presence. But I do look forward to meeting Dave Fackler – the user group lead after me who has been doing an awesome job keeping up the meetings, and Chris Yates – whom I met on twitter and is growing to be a good member of our local #sqlfamily. Our group is scheduled to meet on Wednesday morning for breakfast at the summit.

2 The non celebrity friends network – I like to call it that – we are people who are regular attendees of the conference – none of us are celebrities/MCMs/MVPs. Some are ardent PASS volunteers . We like to support and offer grounding to each other as we grow in our lives and careers. My long time friend from St Louis user group Julie Bloominquest, SQLSaturday champion Pam Shaw, Microsoftie friend Karthika Raman, other friends like  Meher Malakapalli, Dan Brennan and Adam Belebczuk.

3 New people to add to the network – Some people I have only known via twitter or other people’s blogs – Doug LaneNancy Daniels , Theresa Iserman, Andy Galbraith, Joey D Antoni are some of them. I think I have more just not getting names out yet.

The number of people I have known over the years and want to catch up with is simply too long for a blog post…that is what makes the summit worth returning to every single year.

Some posts you may want to read that are similar are from two awesome #sqlgals – Tamera Clark and Mickey Stuewe.

http://mickeystuewe.com/2014/10/29/who-you-gonna-meet/
http://clarkcreations.net/blog/last-minute-thoughts-for-summit-2014

 

Wishing everyone a happy conference!!

 

 

TSQL Tuesday #59 – My hero(es) – The Quiet Achievers

I decided to resume my effort at consistent blogging again..after more than a year..with this week’s TSQL Tuesday Invite – this invite is by Tracy McGibben and is on ”Heroes”. There are many heroes in the SQL world who have inspired me and continue to. But there are two among them whom I wish to single out for this post.

1 Joseph Sack – I met Joe during a Sqlskills Immersion Event at Florida. I had known him to be the former director of MCM program before he joined SQLSkills, and I had a mental image of him to be atleast twice as older than he really was. Joe was much younger, very smart and thorough in what he knew, kind, funny and very easy to be around with. Soon after that event Paul Randal put out the yearly mentoring program that they do, and the candidates each of them had picked to mentor. I was long looking for a mentor – and was a bit saddened that I did not make it. I sent out a personal request to Joe – asking if he would mind mentoring me. Honestly did not expect to hear anything in the affirmative but he responded immediately – yes, he would be happy to. I spent a year on mentoring program with Joe – talking every month on things that mattered to me and asking for his advice, suggestions and like. After a few months we would up good friends who shared each other’s cares and worries rather than just a mentor and mentee. What impressed me about him initially are the same qualities that impress me still – humble,  down-to-earth, hard working and always willing to lend a helping hand. (Unfortunately Joe is no longer on social media or blogosphere for me to add any links). Proud to know you and be your friend, Joe.

2 Wayne Sheffield – I met Wayne as a speaker for one of my SQL Saturdays. That particular SQL  Saturday was not really a great event for me and my team. Two of my most senior volunteers had to depart to attend to some personal duties – I was very short on help and struggling to pull together with many things falling apart. One of the things that ‘fell apart’ were speaker shirts, which were misplaced. I was unable to find Wayne’s shirt – he had come with expectation that he would get one and needless to say, it was not the best experience for either of us(The shirt was found later). But the year after – I went on SQL Cruise Alaska, and joined Wayne and his family the day before for a tour of Seattle underground. During the cruise I got to know him much better and we are good friends. I have since followed his journey towards the MCM and various job changes too.He has  always been there to help me – with SQL advice, professional help, or just lend a listening shoulder. Like Joe – the qualities I admire with Wayne are his patience, humility, hard work, down-to-earthiness and willingness to help.

‘A person is known by the friends they keep’ is an old saying – so if people know me by my friends such as these, am sure I am known well :) As a last word – would like to recommend everyone to find  people they vibe well with, not just people who are celebrities or big names. Find people who understand who you are, and are willing to support, encourage and motivate you. And do the same for them. Attend programs like SQL Skills or the SQL Cruise – they are not just for learning, I  have found some of my best friends this way.

Finding new goals…

The sudden and sad demise of the #sqlmcm program had me thinking on many levels..particularly on future goals and aspirations, and on how to market myself.

To give an introduction of some sort – in my younger years I was not particularly in favor of degrees or certifications. I was strongly of the belief that experience, interest to learn and creativity were the ‘real’ stuff that got you places. I dropped out of a high tech engineering program where I was 1 out of 300 people selected from among nearly 60,000 people who took it, and chose to pursue my life and career based on what I believed I had – interest in technology, creativity and hard work. Needless to say, it was not an easy journey. Particularly in a country like India where degrees and certifications were almost a cultural obsession. After a few years of working poorly paid jobs I went back to school for my masters. My masters degree and the process of doing it taught me many positive things. One, that having a hard goal – such as an exam or someone to rate me gave me better focus than learning on my own. Two, degrees helped you get through visas and other places where you do not have personal interaction with whoever is handling your stuff, and three, it helped you find community among others who had similar degrees. I never went crazy about degrees or certifications, but I did learn their place in the world, the hard way.

In the sql server world, there are many paths to progress. The most common one, by far, is by speaking/blogging/becoming a technical evangelist. There are many without MCM who have gone this way and been remarkably successful. But speaking and blogging unfortunately are not everybody’s goal nor does everyone have the time needed for it. To me – as someone who has a lot of food allergies, travelling intensively is really not a good goal to have. I have tried blogging but my time for it is rather limited and also not had success coming up with something creative to write about, I guess again that needs a lot of experimentation. That is part of the reason I picked the MCM as a possible goal. I was also interested in being differentiated from the average brain dump MCITP down the street by getting to be an MCM – and I did find this a worthy goal. Even saying you are pursuing an MCM at an interview got a lot of appreciative nods and interest. It also got employers to pay for good training programs such as those offered by #sqlskills, which they otherwise would not understand the value of.

Now with that certification gone we are back to the world where there is really not much by way of proof to tell an average employer how different you are from brain dump MCITPs. If you are like me into doing community work such as organizing sql Saturdays or running user groups you may want to use that to some extent but not everyone is highly impressed by community work to hire you, or even give you pointers to jobs (including people in the community itself). And to many of us it is not just about career growth or progress, it is also about acceptance among people you respect and acknowledge.

There is a scene in one of my favorite movies ‘A Beautiful Mind’ – where Professor John Nash – played by Russell Crowe, gets accepted and acknowledged for his intelligence after a nobel nomination. The other professors walk over slowly to him and hand him pens as a token of their respect and his acceptance into their club. I have a pen with the ‘Microsoft certified master’ printed on it – a little gift from the #sqlskills class I attended some years ago. It was my goal and the goal of many others I know to be accepted like John Nash was into the elite #mcm community. It is a sad day to have that taken away from us. It is my sincere hope and wish that all of us will find bigger and better goals to pursue.

Previous Older Entries

Follow

Get every new post delivered to your Inbox.