Monthly Archives: August 2014

Beware of NULLs!

Once again, my apologies for those of my readers, to whom this is trivial… but I think that sometimes something which is trivial to the just-out-of-college person becomes sort of faded after years in industry…

Nevertheless, here is what happened the other day. One of my co-workers rightly noticed, that a medium-size SELECT statement was not using the proper index because the condition was:

field1 =NULL

The problem was actually more than not using the proper index; this condition was a part of a relatively big OR expression, so if this one was not using any index, the bitmap OR-ing could not be used! The proper solution would be one of two: either to use IS NULL or to use =”, in both cases the index will be used as expected.

When this solution was proposed to the query owner, he asked us why Postgres optimizer “does not understand” what it should do. And here comes this “obvious” part, which I want to re-iterate.

As we all remember from our “Introduction to RDBMS” college course, we should never use =NULL, because this is “undefined” expression, which means, that any DBMS can implement it differently, and implementation does not have to be consistent between versions. The correct syntax is “IS NULL”. Granted, we all are used to the fact, that most of industrial databases have some deviations from ANSI standard. That’s why we always need to test, how it actually works.

So, here we are:

select substring ( '222' FROM 4 FOR 7 )=NULL

returns boolean NULL; and

select substring ( '222' FROM 4 FOR 7 )=NULL OR ('aaaa'='bbbb')

also returns boolean NULL, but the query “meant” to return ‘true’ in this case!

Note, that if we the second condition would be true, the whole expression would be true, since “undefined” OR true is “true enough” 🙂

Actually the more interesting thing is, that even with IS NULL this won’t work as expected! Try

select substring ( '222' FROM 4 FOR 7 ) IS NULL


select substring ( '222' FROM 4 FOR 7 ) =''

The first one will return false, and the second true! You know why? Because in Postgres the empty string is not the same, as NULL string!

The moral of the story: trust, but verify, and – be very careful with NULLs!

Leave a comment

Filed under SQL

How to say “yes” and “no” – part two

Another twist of the same problem. When I read about it in the “12 soft skills”, I’ve realized I was “always” doing things that way, but never though about why I choose to act this way.

The situation is common and simple. Somebody suggests “let’s do <something>”. And you firmly believe, that this “something” is wrong. What should you do? Especially when a person is your manager.

The book says: avoid saying “no”. And that’s true. When you say”no, we can’t do this”, it’s a blocker. A person, with whom you talk, won’t even listen for your “that’s why”, “because”, “what we can do instead”, etc.  So what you need to do, is to find a way to say “yes”.  Something like “I agree with you in principle, but I am not sure we can proceed with this plan right away, because…”  Or: “I believe this is a right approach, especially in the long term, but what to you think about doing <…> right now, and take the path you are suggesting later?

Even if what is suggested, does not make any sense at all, try to find something, for which you can say “yes”, and start from acknowledging agreement. As I say in other circumstances focus on what unite us, rather than what divide us.

This approach can really work miracles!

Leave a comment

Filed under People

How to say “yes” and “no” – part one

For a while now I’ve being reading a great book – “12 Essential Skills for Software Architects” by Dave Hendricksen.

This book is really-really awesome, and I am going to write about it in more details, but today I want to talk about one very important topics, touched in this book: how to talk with people. By people I mean our co-workers, our teammates, our managers and our customers.

We often tend to just “speak our mind”. Straight. And it does not necessarily end well. Because – you remember? – a person you are talking to will get only approximately 20% percent of it, by “get” I mean, (s)he will understand it the way you intended things to be understood. And very often these 20% won’t be the ones you think are the most important. So quite often, when you are trying to say: “let’s make this piece of code better!” you are heard like “you do not know how to code!” You see some problems with the suggested design, and you respond: no, this is not going to work! You need to change it! And the only thing which happens – you put you opponent into defensive mode.

Meanwhile, you can always say exactly what you want, just using slightly different words. For example, something like this: I am not sure I like an idea of adding this column… I think, it may cause some problems in X and Y situations. What do you think? I was wondering, whether we could consider Z instead. May be, we can experiment and return to this discussion in a week?

This way you didn’t offend anybody, and people are actually willing to listen to your advice. I love the quote from the above book:

If you wish to make a man your enemy, tell him simply, “You are wrong”. This method works every time.

… to be continued

Leave a comment

Filed under books

How to recruit more women to CS…

This topic has being quite hot for a while, and if you ask me, I will tell you it’s a good thing. However, people often ask me: Hettie, what’s the buzz? Why so suddenly, why now? It looks like some political campaign. What’s the reason?

Well, the reason is, that there are simply too many openings in CS, and while male programmers and data scientists are out there, the employers start thinking, that they are missing a half of a potential pool of candidates – and rightly so!

Look, when women do not even want to try to study computer science, they might not even know they can be good in it! So they will never become CS major grads, and consequently will never become employees at Enova :).

In order to have more female to apply for IT jobs, you first need to have more female, graduating with IT degrees! This article has being sitting in my Inbox for a month. I wanted to write about it, but totally didn’t have time.

It tells about the efforts some top colleges are making to attract more female to IT – we all know that the percentage of female among CS graduates dropped to 18% nationwide from the max of 37% in 1985 (which is my graduation year, BTW :))

Should the courses be “adjusted” to be appealing to more female? Probably not, but some other efforts may be paid off. For example,

Harvey Mudd revised its recruiting brochures to show photos of women, and it hired women as campus tour guides. “We made it very clear that being a female scientist, that’s normal,” Maria Klawe, president of Harvey Mudd, said Tuesday at the Fortune Brainstorm Tech conference in Aspen, Colo.

Other interesting moves include removing the requirement of the previous programming experience as an admissions criterion, which opened the door to girls who have not been exposed to it (Carnegie Mellon). The University of Washington has a program to train high school teachers to teach computer science and host camps and mentoring sessions for young students. The programs are not all gender-specific, but end up recruiting girls because they are less likely to pursue technology classes otherwise (which hits, that the quest to attract more female should start way before admission).

This being said… in about 4 years I am planning 1) still to be with Enova 2)have at least 30% of junior new hires being female.

Should I include this goal into my Individual Development Plan?

Leave a comment

Filed under news